-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInvestigation Grid Macros.txt
232 lines (148 loc) · 6.31 KB
/
Investigation Grid Macros.txt
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
1. when directed to invcestigation grid, last empty row to enter new case info (DONE)
2. clear all filters (DONE)
3.freeze top pane (DONE)
4. unhide all columns (DONE)
5. hide columns filter needs to go back to the last active cell (DONE)
6. case number entered in inputbox for edit/new gets put into grid corrections/newly added needs review (DONE)
7. adding new case automatically enters first row formulas (DONE)
8.put the casenumber entered into the input box in column I:I (DONE)
9.entering new case: msgbox asking how many rows,inserting rows and additional rows formulas (DONE)
10. Time and date of case number add on corrections grid (DONE)
11.When opening workbook, go right to the Getting Started sheet (DONE)
new rows also selecting the right color pattern and formatting or seperate each bordered section by a different shade
Search for cases with comments or cases with pending CAPS
FID NUMBER additional row fill from above
When fill additional rows, block off the cells that should not be filled
additional rows: fill pattern for cells that should not be filled in or LOCK /protect the cells in range A:V and AG:AS and AU:AV
If cell is <> Null or If cell is <> "" Then fill fill first row and fill additional rows
Protect to not allow Sort in columns
Have to fix drop down in column A if the protect macro is going to work
Private Sub Worksheet_Change(ByVal Target As Range)
Dim N As Long
N = Target.Row
If Intersect(Target, Range("A:A")) <> "" And Target.Text <> "CLOSED" Then Cells.Locked = True 'if A has closed in it protect
If Intersect(Target, Range("A:A")) Is Nothing And Intersect(Target, Range("A:A")).Offset(1, 1) <> "" Then Cells.Locked = True
'Else: Cells.Locked = False
ActiveSheet.Unprotect
Range("A" & N & ":AV" & N).Locked = True
ActiveSheet.Protect
End Sub
using AND
If Lcase(Cells(i, "A").Value) = "miami" And _
Lcase(Cells(i, "D").Value) = "florida" Then
Cells(i, "C").Value = "BA"
Private Sub Worksheet_Change(ByVal Target As Range)
Dim N As Long
N = Target.Row
If Intersect(Target, Range("A:A")) <> "" Then Exit Sub 'If A has something in it then dont protect
If Target.Text <> "CLOSED" Then Cells.Locked = True 'if A has closed in it protect
If Intersect(Target, Range("A:A")) Is Nothing Then Cells.Locked = True
ActiveSheet.Unprotect
Range("A" & N & ":AV" & N).Locked = True
ActiveSheet.Protect
End Sub
Sub ProtectTheSheet()
Dim chCell As Range
Dim chRng As Range
'Clear the default status
ActiveSheet.Unprotect
Range("A7:I35").Locked = False
Set chRng = ActiveSheet.Range("A7:I35")
'Check cell value in body and lock cells with content
For Each chCell In chRng.Cells
If chCell.Value <> "" Then Cells.Locked = True
Next chCell
ActiveSheet.Protect
End Sub
Sub CellLocker()
Cells.Select
' unlock all the cells
Selection.Locked = false
' next, select the cells (or range) that you want to make read only,
' here I used simply A1
Range("A1").Select
' lock those cells
Selection.Locked = true
' now we need to protect the sheet to restrict access to the cells.
' I protected only the contents you can add whatever you want
ActiveSheet.Protect DrawingObjects:=false, Contents:=true, Scenarios:=false
End Sub
If you say Range("A1").Select, then it locks only A1. You can specify multiple cells to be locked by specifying as follows:
A3:A12,D3:E12,J1:R13,W18
This locks A3 to A12 and D3 to E12 etc.
http://www.rondebruin.nl/win/s9/win006.htm for the base of the code i used for the inputbox
Copy cells to another sheet with Find (could use this for moving rows into the substantiated.indicated sheet)
The example below will copy all cells with a E-Mail Address in the range Sheets("Sheet1").Range("A1:E100") to a new worksheet in your workbook. Note: I use xlPart in the code instead of xlWhole to find each cell with a @ character.
Sub Copy_To_Another_Sheet_1()
Dim FirstAddress As String
Dim MyArr As Variant
Dim Rng As Range
Dim Rcount As Long
Dim I As Long
Dim NewSh As Worksheet
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Fill in the search Value
MyArr = Array("@")
'You can also use more values in the Array
'myArr = Array("@", "www")
'Add new worksheet to your workbook to copy to
'You can also use a existing sheet like this
'Set NewSh = Sheets("Sheet2")
Set NewSh = Worksheets.Add
With Sheets("Sheet1").Range("A1:Z100")
Rcount = 0
For I = LBound(MyArr) To UBound(MyArr)
'If you use LookIn:=xlValues it will also work with a
'formula cell that evaluates to "@"
'Note : I use xlPart in this example and not xlWhole
Set Rng = .Find(What:=MyArr(I), _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then
FirstAddress = Rng.Address
Do
Rcount = Rcount + 1
Rng.Copy NewSh.Range("A" & Rcount)
' Use this if you only want to copy the value
' NewSh.Range("A" & Rcount).Value = Rng.Value
Set Rng = .FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address <> FirstAddress
End If
Next I
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Loops for survey responses
Dim i As Integer
i = 1
Do While i < 6
Cells(i, 1).Value = 20
i = i + 1
Loop
First we need to find first blank row in column and then select the cell.
Sub sb1_IFCondition()
'ActiveCell.Select
If Range("H2") < 45 Then Range("I2") = "Yes"
End Sub
Sub sb1_IFCondition()
'ActiveCell.Select
If Range("H2") < 45 Then
Range("I2") = "Yes"
End Sub
Sub sbForLoop()
Dim iCntr As Integer
For iCntr = 1 To 5
msgbox iCntr
Next
End Sub
So maybe this would work...