MsgBox Keeps Popping Up

xiaoying

New Member
Joined
Dec 6, 2019
Messages
26
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I realised the mistake was that my modules contains a message box too ? Sorry for not checking before posting this on the forum. This thread is closed.
 
Upvote 0

Forum statistics

Threads
1,215,248
Messages
6,123,877
Members
449,130
Latest member
lolasmith

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top