This code gives me a compiler error, "Expected Array". Does anybody know why this is? I want my array to be filled with the corresponding values within the rows that fit my given parameters.
A bonus question- Once I figure that out, I want to count the unique # of values that got entered into that array. However, I am mainly concerned with my first error, and I am greatly appreciative of any help or guidance provided.
Dim dateCheck As String
Dim lastRow As Long
Dim L As Integer
Dim I As Long
Dim shipDay As Date
Dim search As String
Dim myArray As Variant
For L = 0 To 21 ' Execute code for whole month
shipDay = Worksheets("June Canada").Cells(L + 10, 10).Text 'Check specific ship days
For I = 1 To Worksheets("Sheet1").UsedRange.Rows.Count ' Check every row of worksheet
search = Worksheets("Sheet1").Cells(I, 12).Value ' Variable to check for CAN vs USA
If ((InStr(1, search, "CAN", vbBinaryCompare) = 1) _
And (Worksheets("Sheet1").Cells(I, 8) = shipDay) _
And (Worksheets("Sheet1").Cells(I, 6).Text = "Invoice")) Then
ReDim myArray(lb To ub)
lb = 0 ' lower bound = 0
ub = WorWorksheets("Sheet1").UsedRange.Rows.Count ' upper bound is max # of rows
myArray() = Worksheets("Sheet1").Cells(I, 10).Text ' Add the variable values to the dynamic array
End If
Next I
' Count # of unique values in unique ()
' Worksheets("JUNE canada").Cells(L + 10, 8).Value = ??? 'Enter # of unique values into sheet
Next L