0

The following code gives the error "subscript out of range":

Sub Workbooks2(str)
     Workbooks.Open (ThisWorkbook.path & "\" & str)
     Workbooks(ThisWorkbook.path & "\" & str).Close ' <<<<< subscript out of range error
End Sub
Francis
  • 702
  • 9
  • 21

1 Answers1

0

The following works (removed the path to the file in the Close command):

Sub Workbooks2(str)
     Workbooks.Open (ThisWorkbook.path & "\" & str)
     Workbooks(str).Close 
End Sub
Francis
  • 702
  • 9
  • 21