ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Passing a value to a variable from Userform (https://www.excelbanter.com/excel-programming/272039-passing-value-variable-userform.html)

Neal Steiner

Passing a value to a variable from Userform
 
Dear Most Valued Experts,

I have a Userform where I am asking for information.
In the code, when the user clicks OK, if the amount typed
in is incorrect, I have a msgbox asking if the user wants
to continue. If the answer is no, I need to exit the
userform and go into another macro. If the answer is yes,
to continue with the userform. What is the best way to
set this up? Thanks.

Neal

Neal[_2_]

Passing a value to a variable from Userform
 
Tom,

Thanks for your answer. It works like a charm!


-----Original Message-----
In a general module at the top

Public bQuit as Boolean

Sub Showform()
bQuit = False
Userform1.Show
if bQuit then exit sub
' code to continue

End Sub

Private Sub cmdOK_Click()
if Textbox1.Text = "" then
res = msgbox("Do you want to continue, vbYesNo")
if res = vbNo then
bQuit = True
unload me
end if
Msgbox "Please fix the value in the box"
Textbox1.Setfocus
Else
me.hide ' or unload me
end if
End Sub

I am sure there are many other ways to attack this

problem and more
knowledge of the situation may drive different solutions

as well.

Regards,
Tom Ogilvy

"Neal Steiner" wrote in message
...
Dear Most Valued Experts,

I have a Userform where I am asking for

information.
In the code, when the user clicks OK, if the amount

typed
in is incorrect, I have a msgbox asking if the user

wants
to continue. If the answer is no, I need to exit the
userform and go into another macro. If the answer is

yes,
to continue with the userform. What is the best way to
set this up? Thanks.

Neal



.



All times are GMT +1. The time now is 05:57 AM.

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