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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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,216,500
Messages
6,131,015
Members
449,615
Latest member
Nic0la

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