I'm getting Subscript out of range on Debug.Print myarr(i).
Dim ws As Worksheet: Set ws = Sheets("Sheet1")
Dim myarr as Variant, i as Long
myarr = Array(ws.Range("A2:A" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row))
For i = LBound(myarr) To UBound(myarr)
Debug.Print myarr(i)
Next i
I have validated the range with (below) which shows A2:A5
Msgbox ws.Range("A2:A" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row)).Address (false, false)
I have also tried changing myarr to
= ws.Range("A2:A" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row)
= ws.Range("A2:A" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row).Value
= Array(Temp.Range("A2:A" & Temp.Range("A" & Temp.Rows.Count).End(xlUp).Row).Value)
First one gives Subscript out of range, 2nd two give type mismatch
Fairly new to working with arrays, and I dont know what I'm missing here. Am I loading the array incorrectly or trying to view the items in array incorrectly?