I have a code to run through columns and staggered rows to collect data into an array. The staggered layout becomes one row in the array. It runs successfully for the first 2 groups of data but towards the end of the 3rd group it produces an error message "Object variable not set (Error 91). It trips on the line in red below.
What might be the problem?
thanks
What might be the problem?
thanks
VBA Code:
With ActiveSheet
For r = r + 1 To LastRow
For i = Counter To LastRow Step 1
If Cells(Counter, 1).Value <> Cells(Counter + 1, 1).Value Then
Exit For
End If
Counter = Counter + 1
Next i
'group end row
EndRow = Counter
For c = 1 To 12 'columns A to L
Set startCell = Cells(StartRow, c)
Set Rng = Range(Cells(StartRow, c), Cells(EndRow, c))
If WorksheetFunction.CountA(Rng) = 0 Then
Aptdatarray(r, c) = ""
Else
[COLOR=rgb(184, 49, 47)]Aptdatarray(r, c) = Rng.Find(What:="*", After:=Cells(StartRow, c)).Value [/COLOR]
End If
Next c
StartRow = Counter + 1
Counter = Counter + 1
If StartRow >= LastRow Then
Exit Sub
End If
Next r
End With