I would like a VBA script that can close multiple files. There can be up to 50 files open at one time with the name of "Metrics Table (2) (*)", where the * is any number between 1 and 1000. Example "Metrics Table (2) (16)". Data is pulled from these files and then the file is no longer needed (it actually could and will be manually deleted) but at least I need these files to close when the macro is run. The file in which the macro is run is the master file and will NOT be closed.
Here is a code I found that I imagine could be modified to use a wildcard somehow.
I tried to use this one, but there could be other workbooks open that I don't want to close
Thanks for any help.
Here is a code I found that I imagine could be modified to use a wildcard somehow.
VBA Code:
Sub CloseWorkbook()
Workbooks("Metrics Table (2) (16).xlsx").Close SaveChanges:=False
I tried to use this one, but there could be other workbooks open that I don't want to close
VBA Code:
Sub CloseAllWbksExceptCurrent()
Dim wb As Workbook
For Each wb In Workbooks
If wb.Name <> ThisWorkbook.Name Then
wb.Close SaveChanges:=False
End If
Next wb
End Sub
Thanks for any help.