Hi Forum Community ? I am trying to run codes from my user form which includes the calling of functions from my modules. The functions will run depending on whether the check boxes are checked when the user form is running. However, after running each functions, the message box will pop up for every one of them. All the functions are in separate modules. What I want to achieve is the message box popping up only after all the functions have run. Would really appreciate anyone's help!!
VBA Code:
Private Sub CommandButton1_Click()
Dim question As Integer
Dim finish As Integer
question = MsgBox("Are you sure you want to generate these letters?", vbYesNo + vbQuestion + vbDefaultButton2, "Generate Letter")
'used vbYesNo so that user is force to answer and they will be more sure of what is going on
'vbOKOnly will have only Ok and the cross button
'vbDefaultButton2 means second button is default
'https://www.ozgrid.com/forum/index.php?thread/127920-run-different-macros-based-on-userform-checkbox-values/
If question = vbYes Then
If CheckBox1.Value = True Then
Call GenerateLOR
End If
If CheckBox2.Value = True Then
Call GenerateEL
End If
If CheckBox3.Value = True Then
Call GenerateDraftReport
End If
finish = MsgBox("Automation of letter is done", vbOKOnly + vbInformation + vbDefaultButton1, "Generate Letter")
GenerateLetters.Reset ' call Public Sub Reset(), reset checkbox values to prevent confusion and to show end of automation
Else: End If
End Sub