I am trying to extract text data from an Excel sheet into an array (defined as a variant in this case).
The below code does not return desirable results: When I try to access an element in the SearchItems
variant array, an error pops up saying subscript out of range.
However when I run UBound(SearchItems)
the system returns the value of LR (instead of LR-1?).
In any case does that indicate that data if already loaded onto the array?
Sub Testing()
Dim SearchItems As Variant
Dim LR As Integer
LR = Sheets("MySheet").Cells(Rows.Count, "A").End(xlUp).Row 'Get number of cells in column A
SearchItems = Sheets("MySheet").Range("A1:A" & LR).Value
End Sub