MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Message Box HELP


Posted by Mike on July 24, 2000 8:22 AM

I have a message box with a yes or no option.
how do you make an if statement for the yes or no?? right not yes and no are doing the same event.
THANKS!


Posted by Ryan on July 24, 0100 10:25 AM

Mike,

The Yes/No option for the message box returns either vbYes or vbNo. You have two options to choose from:

1)
Dim ans as String

ans = MsgBox(Prompt,buttons,Title)
If ans = vbYes Then
Code for yes
Else
Code for no
End if

2)
If MsgBox(Prompt,buttons,Title) = vbYes Then
Code for yes
Else
Code for no
End if

Hope this helps

Ryan