Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default End a procedure from a UserForm

I use a MsgBox with vbYesNoCancel to end a procedure if the No button is
clicked. However, the end users don't take the time to read the message and
just click Yes to get past it.

I want to use a LARGE UserForm with Yes & No command buttons to accomplish
the same thing. If the end user clicks Yes, the UserForm will unload and the
procedure will continue. What code can I put into the No command button to
end the procedure that launched the UserForm when the No button is clicked?

Thanks,

Sam
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default End a procedure from a UserForm

For a userform, you could use a global boolean variable like bContinue, e.g.

' In a regular module:

Public bContinue As Boolean

Sub Test()

UserForm1.Show

If bContinue Then
MsgBox "Clicked Yes"
Else
MsgBox "Clicked No"
' The other procedure looks at
' bContinue to decide what to do
End If

End Sub

' In the userform:

Private Sub cmdNo_Click()
bContinue = False
Unload Me
End Sub


One other possibility if you want to try to get more out of the message box
dialog is to use the exclamation:

If MsgBox("Some message", vbYesNoCancel + vbExclamation) = vbNo Then

End If

--
Regards,
Tim Zych
http://www.higherdata.com
Workbook Compare - Excel data comparison utility

http://www.higherdata.com/sql/batchsqlfromexcel.html
Create batch SQL from Excel


"Sam" wrote in message
...
I use a MsgBox with vbYesNoCancel to end a procedure if the No button is
clicked. However, the end users don't take the time to read the message
and
just click Yes to get past it.

I want to use a LARGE UserForm with Yes & No command buttons to accomplish
the same thing. If the end user clicks Yes, the UserForm will unload and
the
procedure will continue. What code can I put into the No command button to
end the procedure that launched the UserForm when the No button is
clicked?

Thanks,

Sam



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
Cancel a Procedure through a Userform jumpjump[_3_] Excel Programming 1 August 30th 05 09:52 AM
Exiting a procedure with a userform jumpjump[_4_] Excel Programming 2 August 30th 05 09:04 AM
userform output to procedure shellshock Excel Programming 2 July 29th 05 11:31 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Quit UserForm and Procedure Maria[_7_] Excel Programming 6 September 5th 04 11:29 PM


All times are GMT +1. The time now is 03:32 PM.

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"