View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Cancel button on messagebox/inputbox

Greg,
You need to check the return value. e.g.

If MsgBox("Is this [Some Value] correct ?", vbYesNoCancel) = vbCancel Then

With Input boxes, it depends which you are using. According to Help :
1 - VBA.InputBox Function, "If the user clicks Cancel, the function returns
a zero-length string ("")."
2 - Application.InputBox Method, "If you click the Cancel button, InputBox
returns False."

NickHK

"Greg" wrote in message
...
I am just wondering how to stop this from happening.

I have a series of question on a inputbox and when i click the cancel

button
it just goes to the next one in line. How do I get excel to go back to

the
userform called "main" when either the cancel or the x button is pressed?

Also will this work on a messagebox as well?

Thanks in advance

Greg