populate message box from the second running the macro

Mussa

Board Regular
Joined
Jul 12, 2021
Messages
245
Office Version
  1. 2019
  2. 2010
Hi
I have procedure to populate message box before the run my macro
VBA Code:
ans = MsgBox("are you sure you want to continue ?", vbYesNo)
If ans = vbNo Then Exit Sub
'my macro
'
'
what I want the message box should show from the second running when click the button for my macro , not from the first time click the button , is it possible , guys?
 
Hi Dave ,
my goal if i run the first time then will call my macro , also if run again then will show message and if I click ok should call my macro , but if I click no then should not call my macro .

Try this update & see if this now does what you want

VBA Code:
Sub Mussa()
  
    With Sheet1.Range("A1")
        If Val(.ID) = xlDialogDisplay Then
            'display msgbox
            If MsgBox("are you sure you want To continue ?", 36, "Continue") = vbNo Then Exit Sub
        End If
        .ID = xlDialogDisplay
    End With
   
    Call mymacro
   
End Sub

Dave
 
Upvote 0
Solution

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
also your guessing is too stupid !
The phrase "stupid question" is a reference to the question that PeteWright was about to ask. Not yours. Your response, however, was staggeringly rude.
 
Upvote 0
Wow Dave !
that's excellent , what I wanted.
thank you so much for your help .:)
 
Upvote 0
Use the code I posted in post #7 and put your macro code where it says "my macro"
I prefer post # 15 and works .
thank you for your time & help .;)
 
Upvote 0

Forum statistics

Threads
1,215,588
Messages
6,125,692
Members
449,250
Latest member
azur3

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