Reputation: 1795
I'm trying to open up a series of xlm files stored in an array, but the error keeps popping up that says that the subscript is out of range. Any advice? Thanks
Dim AllFiles() As String
Dim count, test, StartRow, LastRow, LastColumn As Long
test = count
Do While (test >= 0)
Workbooks.Open Filename:=AllFiles(test) 'subscript out of range
test = test - 1
Loop
Upvotes: 0
Views: 306
Reputation: 53126
This doesn't address the root cause (what ever that may be) but is a more natural way to loop an array
For test = UBound(AllFiles) to LBound(AllFiles) Step -1
Workbooks.Open Filename:=AllFiles(test)
Loop
By the way, your dim statement Dim count, test, StartRow, LastRow, LastColumn As Long
declares all items except LastColumn
as Variant
Upvotes: 2