forked from christwellman/VBAMacros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorksheet_ChangeEvents.vb
163 lines (123 loc) · 5.84 KB
/
Worksheet_ChangeEvents.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
Sub Worksheet_Change(ByVal Target As Excel.Range)
'use this to automatically update cells and move rows when values in teh sheet are changed
Dim ws0 As Worksheet
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim ws3 As Worksheet
Dim ws4 As Worksheet
Dim ws5 As Worksheet
Dim ws6 As Worksheet
Dim ws7 As Worksheet
Dim ws8 As Worksheet
Dim LR As Long
Dim C As Range
Dim Brendon As Range
Dim David As Range
Dim Erik As Range
Dim copyrange As Range
Set ws0 = Sheets("LOVs")
Set ws1 = Sheets("Project Pipeline")
Set ws2 = Sheets("Project Tracking - BBODEN")
Set ws3 = Sheets("Project Tracking - SMILESNI")
Set ws4 = Sheets("Project Tracking - EVOGEL")
Set ws5 = Sheets("Closed Projects")
Set ws6 = Sheets("Project Tracking - MILASKIN")
Set ws7 = Sheets("Project Tracking - AMALAN")
Set ws8 = Sheets("Complete - Presales - Scoping")
Set Brendon = ws0.Range("BrendonsTeam")
Set Scott = ws0.Range("ScottsTeam")
Set Erik = ws0.Range("EriksTeam")
'Automaticly move for staffing hinges on Column "R"
If Target.Column = 20 Then
Thisrow = Target.Row
assignedPM = Target.Value
If assignedPM <> vbNullString Then
'Test For Brendon
If (WorksheetFunction.CountIf(Brendon, assignedPM) > 0) Then
m = MsgBox("Confirm Assignment and move to Brendon's Tab", vbYesNo + vbMsgBoxSetForeground, "Assign and Move")
If m = vbYes Then
'Update DCPM Assigned Date
ActiveSheet.Cells(Thisrow, 38).Value = Now()
'Call Copy to
ws1.Cells(Thisrow, 1).Resize(1, 52).Copy
'find the last row on teh destination sheet
moverow = Lastrow(ws2)
ws2.Cells(moverow, 1).PasteSpecial xlPasteAll
'Remove source row
ws1.Cells(Thisrow, 1).EntireRow.Delete
End If
'Test for Scott
ElseIf (WorksheetFunction.CountIf(Scott, assignedPM) > 0) Then
m = MsgBox("Confirm Assignment and move to Scott's Tab", vbYesNo + vbMsgBoxSetForeground, "Assign and Move")
If m = vbYes Then
'Update DCPM Assigned Date
ActiveSheet.Cells(Thisrow, 38).Value = Now()
'Call Copy to
ws1.Cells(Thisrow, 1).Resize(1, 52).Copy
'find the last row on teh destination sheet
moverow = Lastrow(ws3)
ws3.Cells(moverow, 1).PasteSpecial xlPasteAll
'Delete Row from Pipeline
ws1.Cells(Thisrow, 1).EntireRow.Delete
End If
'Test for Erik
ElseIf (WorksheetFunction.CountIf(Erik, assignedPM) > 0) Then
m = MsgBox("Confirm Assignment and move to Erik's Tab", vbYesNo + vbMsgBoxSetForeground, "Assign and Move")
If m = vbYes Then
'Update DCPM Assigned Date
ActiveSheet.Cells(Thisrow, 38).Value = Now()
'Call Copy to
'What to Copy
ws1.Cells(Thisrow, 1).Resize(1, 52).Copy
'find the last row on teh destination sheet
moverow = Lastrow(ws4)
ws4.Cells(moverow, 1).PasteSpecial xlPasteAll
'Delete Row from Pipeline
ws1.Cells(Thisrow, 1).EntireRow.Delete
End If
'Else
' Range("B" & ThisRow).Interior.ColorIndex = xlColorIndexNone
End If
End If
End If
'Move to Closed tab if PID is closed
If Target.Column = 7 Then
Thisrow = Target.Row
'Check to see if PID is Delivery Close
If ActiveSheet.Cells(Thisrow, 7).Value = "Delivery Close" Then
'Update Delivery Close Date
ActiveSheet.Cells(Thisrow, 41).Value = Now()
ElseIf ActiveSheet.Cells(Thisrow, 7).Value = "Closed" Then
m = MsgBox("Are you sure you want to move this to the 'Closed' tab?", vbYesNo + vbMsgBoxSetForeground, "Move Project?")
If m = vbYes Then
'Update Closed Date
ActiveSheet.Cells(Thisrow, 42).Value = Now()
'Update DCPM Status
ActiveSheet.Cells(Thisrow, 35).Value = "Closed"
'Find the last row on teh Closed Tab
moverow = Lastrow(ws5) + 1
'copy used range in active row
ActiveSheet.Cells(Thisrow, 1).Resize(1, 52).Copy
ws5.Cells(moverow, 1).PasteSpecial xlPasteAllExceptBorders
'Remove source row
ActiveSheet.Cells(Thisrow, 1).EntireRow.Delete
Else
End If
ElseIf ActiveSheet.Cells(Thisrow, 7).Value = "Cancelled" Then
m = MsgBox("Are you sure you want to move this to the 'Complete' tab?", vbYesNo + vbMsgBoxSetForeground, "Move Project?")
If m = vbYes Then
'Update Closed Date
ActiveSheet.Cells(Thisrow, 42).Value = Now()
'Update DCPM Status
ActiveSheet.Cells(Thisrow, 35).Value = "Cancelled"
'Find the last row on teh Closed Tab
moverow = Lastrow(ws5) + 1
'copy used range in active row
ActiveSheet.Cells(Thisrow, 1).Resize(1, 52).Copy
ws8.Cells(moverow, 1).PasteSpecial xlPasteAllExceptBorders
'Remove source row
ActiveSheet.Cells(Thisrow, 1).EntireRow.Delete
End If
End If
End If
End Sub