Forum Discussion
SamFares
May 28, 2021Brass Contributor
VBA code to remind the Excel sheet user to run the Macro
Hello, I have created a macro for design in an excel sheet that has two tabs in it. What is the VBA code if a user make any input changes to remind him in the end before he exists to run the des...
- May 28, 2021
You have copied the code into the code module of the CJ Design and Addl Composite Stage Loads sheets instead of into the ThisWorkbook module.
HansVogelaar
May 28, 2021MVP
The following will work if the workbook only prompts to be saved when it is closed if the user has changed something.
Press Alt+F11 to activate the Visual Basic Editor.
Double-click ThisWorkbook under Microsoft Excel Objects.
Copy the following code into the ThisWorkbook module:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not Me.Saved Then
Select Case MsgBox("Do you want to run the design macro now?", vbQuestion + vbYesNoCancel)
Case vbYes
Call DesignMacro
Case vbNo
' Just continue
Case vbCancel
Cancel = True
End Select
End If
End Sub
where DesignMacro is the name of the macro that should be run.
SamFares
May 28, 2021Brass Contributor
I will try it. Thank you so much Hans!