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

razzandy

Active Member
Joined
Jun 26, 2002
Messages
388
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 :)
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Jay Petrulis

MrExcel MVP
Joined
Mar 17, 2002
Messages
2,040
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>
 

razzandy

Active Member
Joined
Jun 26, 2002
Messages
388
Office Version
  1. 2007
Platform
  1. Windows
Thanks very much Jay!

I can go to bed now!

Cheers

Ryan UK :) :wink:

P.S. It's 23:38 here!! :(
 

KniteMare

Board Regular
Joined
Mar 4, 2002
Messages
238
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?
 

Forum statistics

Threads
1,148,339
Messages
5,746,177
Members
423,998
Latest member
eakenila

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
Top