I have a code in which it goes through all the rows and looks to see if column I contains the word 'MISS' and adds that to the array. I now want it to know those rows are stored into it, and instead store the rows that aren't already in an array into a different array. My current code is:
Sub tester()
max_targets = 6
Dim RowsToMiss(1 To 6)
lRow = 2
Do Until Sheets("Result").Cells(lRow, 1) = ""
If Sheets("Result").Cells(lRow, 9) = "MISS" Then
RowsToMiss(Sheets("Result").Cells(lRow, 4)) = lRow
End If
lRow = lRow + 1
Loop
lRow = 2
Do Until Sheets("Result").Cells(lRow, 1) = ""
If RowsToMiss(Sheets("Result").Cells(lRow, 4)) <> lRow Then
'read the row in!
Else
End If
lRow = lRow + 1
Loop
End Sub
If you need to add values to a collection dynamically, VBA provides the type
Collection
, which is a better thanArray
, because its size can be increased dynamically. Thus, in your case, you need to loop through the second column, check the values in the cells and add them to one of the two available collections:This is something that you would get in the immediate window CTRL+G, if the 2,3,4 & 8 cell of the 1. column are with the word "MISS":
Like @brainac I'm unsure what you are asking, but have taken a punt. This creates another array which stores the row numbers which do not contain MISS.