Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default 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



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variable values to userform control KJ-clueless Excel Discussion (Misc queries) 2 November 27th 07 10:51 PM
Import into Access from Excel, passing a variable for the field... [email protected] Excel Worksheet Functions 1 April 12th 07 09:44 AM
Passing string as array variable (Pivot VBA) klingongardener Excel Discussion (Misc queries) 2 December 23rd 06 07:58 PM
Passing Variable Number of Arguments to a Sub blatham Excel Discussion (Misc queries) 4 December 10th 05 10:36 AM
Passing Variable to LINEST RW Excel Worksheet Functions 5 May 24th 05 07:00 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"