vbYesNo, change carriage return

G

Guest

Hie, can anyone help with the following:

When you create a message box using vbYesNo function, when the box appears
on screen, is it possible to change the set-up so that when you press return
(carriage return) it will automatically select the "No" option. Standard
vbYesNo defaults to "Yes" option when you hit carriage return.

Any help would be much appreciated.

Thank you
 
R

Ron Coderre

Put this macro in a General Module and run it:

Sub MsgBoxButtonTest()
MsgBox _
Title:="Default Button Test", _
Prompt:="Is this an aardvark?", _
Buttons:=vbQuestion + vbYesNo + vbDefaultButton2
End Sub

Then see Excel VBA Help for MsgBox and study the various Button argument
values.

Does that help?
--------------------------

Regards,

Ron (XL2003, Win XP)
Microsoft MVP (Excel)
 
G

Guest

Your code works.
Thanks for your help Ron
--
jj


Ron Coderre said:
Put this macro in a General Module and run it:

Sub MsgBoxButtonTest()
MsgBox _
Title:="Default Button Test", _
Prompt:="Is this an aardvark?", _
Buttons:=vbQuestion + vbYesNo + vbDefaultButton2
End Sub

Then see Excel VBA Help for MsgBox and study the various Button argument
values.

Does that help?
--------------------------

Regards,

Ron (XL2003, Win XP)
Microsoft MVP (Excel)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top