ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cancel button on messagebox/inputbox (https://www.excelbanter.com/excel-programming/377086-cancel-button-messagebox-inputbox.html)

Greg[_33_]

Cancel button on messagebox/inputbox
 
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



NickHK

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






All times are GMT +1. The time now is 01:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com