I’m trying to operate a MsgBox with the VBYesNo extention?

razzandy

Active Member
Joined
Jun 26, 2002
Messages
399
Office Version
  1. 2007
Platform
  1. Windows
Can somebody give me a simple example of how to use a massage box with the vbYesNo extension?

Any help will be much appreciated

Many Thanks

Ryan UK :smile:
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,

Assign the result to a variable and test the variable.

<pre>Sub test()
Dim x

x = MsgBox("Do you want to say hi to Jay?", vbYesNo)
If x = vbYes Then
MsgBox "Hi to you, too!"
Else
MsgBox "OK, I'll let it slide this time."
End If

End Sub</pre>
 
Upvote 0
Thanks very much Jay!

I can go to bed now!

Cheers

Ryan UK :smile: :wink:

P.S. It's 23:38 here!! :sad:
 
Upvote 0
No variable is needed; by assiging the If statement directly to the Message Box statement. You can do this because the YesNo is a testable condition.

Like this:


If MsgBox("Do you want to say hi to Jay?", vbYesNo) = vbYes Then

MsgBox "Hi to you, too!"
Else
MsgBox "OK, I'll let it slide this time."
End If


Yours in EXCELent Frustraation

KniteMare


Computers are for gaming. Who invented this silly work stuff anyway?
 
Upvote 0

Forum statistics

Threads
1,222,150
Messages
6,164,242
Members
451,882
Latest member
Bigtop

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