1 year ago

#351520

test-img

Lal Sahab

Syntax is correct but showing Subscript out of range (Runtime error 9)

Not sure why I'm getting subscript out of range error on this code but as per my understandings the code is correct. This code was working fine few hours back but now getting this error. Can anyone help on this. Restarted my system several times but getting this error again and again.

Dim workbookNames As Variant
workbookNames = Array("Book1.xlsm", "Book2.xlsm", "Book3.xlsm", "Book4.xlsm")

Dim i As Long
For i = LBound(workbookNames) To UBound(workbookNames)
    
    Dim wb As Workbook
    Set wb = Workbooks(workbookNames(i)) -----**SUBSCRIPT OUT OF RANGE**

vba

automation

excel-automation

0 Answers

Your Answer

Accepted video resources