Hello,
Trying to figure out the vba code which can help me to close all opened workbooks except the active one which has macro. Below is my code. But it does not close any workbook.
Please help. Thank you in advance.
Trying to figure out the vba code which can help me to close all opened workbooks except the active one which has macro. Below is my code. But it does not close any workbook.
Please help. Thank you in advance.
Code:
Sub CloseOtherWorkbook()
Dim WB As Workbook
Windows("Master file.xlsm").Activate
Application.ScreenUpdating = False
For Each WB In Application.Workbooks
If Not (WB Is Application.ActiveWorkbook) Then
WB.Close
End If
Next
Application.ScreenUpdating = True
End Sub