Reputation: 302
I have this VBA code that loops through an array (in this case, supplier_reports()) and it works fine. I was wondering if anyone know if there is a way to get the element number when working with the value in the array:
For Each x In supplier_reports
Workbooks.Open (x)
element_number = x
next x
In this case element number just becomes the value of x, not it's element number in the array.
Thanks
Upvotes: 0
Views: 524
Reputation: 458
You can use a For Loop instead of For Each.
Eg.
For I = LBound(supplier_reports) To UBound(supplier_reports)
Workbooks.Open (supplier_reports(I))
element_number = I
Next
Upvotes: 3