I have written code to close all workbooks except the current workbook where I run the macro
The Macro closes all the workbooks, but I want to suppress all messages including any message box that pops up in the workbook to be closed
the following macro is placed in the code in the sheet on the source workbook to be closed, which I must suppressed in the macro above when closing as the files do not need not be saved
your assistance in resolving this is most appreciated
The Macro closes all the workbooks, but I want to suppress all messages including any message box that pops up in the workbook to be closed
Code:
Sub CloseOtherWorkbooks()
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
End With
Dim WB As Workbook
For Each WB In Workbooks
If Not (WB Is ActiveWorkbook) Then WB.Close SaveChanges:=False
With Application
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
Next
End Sub
the following macro is placed in the code in the sheet on the source workbook to be closed, which I must suppressed in the macro above when closing as the files do not need not be saved
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.CutCopyMode = False
If MsgBox("Have you entered the month and Year?", vbYesNo + vbQuestion) = vbNo Then
Sheets("Summary").Select
Cancel = True
End If
Application.CutCopyMode = False
End Sub
your assistance in resolving this is most appreciated