Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default How to elegantly end a main procedure from a userform command button?

Hello--I am looking for a tidy way to end a main procedure from a
userform command button. One idea that might work (say the newsgroups)
is to to run a boolean function procedure that returns a value, False
if certain conditions are met. Then one could check for a false value
in the main procedure before continuing. However, I am having trouble
connecting userform buttons with function rather than sub procedures. I
am sure that this is a common problem. Can anyone suggest an elegant
way out? Thanks. -Abe

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default How to elegantly end a main procedure from a userform command butt

Whe you click the button have the button click procedure run your boolean
functions to determine the proper course of action...

Private Sub CommandButton1_Click()
if this = false then exit sub
if That = true then
msgbox "Sorry but it's time to go now..."
else
'do your stuff
end if
End Sub

private function This() as boolean
This = True
end function

private function That() as boolean
That = False
end function

--
HTH...

Jim Thomlinson


" wrote:

Hello--I am looking for a tidy way to end a main procedure from a
userform command button. One idea that might work (say the newsgroups)
is to to run a boolean function procedure that returns a value, False
if certain conditions are met. Then one could check for a false value
in the main procedure before continuing. However, I am having trouble
connecting userform buttons with function rather than sub procedures. I
am sure that this is a common problem. Can anyone suggest an elegant
way out? Thanks. -Abe


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
Simplify Command Button Procedure Kenny Excel Discussion (Misc queries) 2 October 14th 07 09:13 PM
Enable Command Button Procedure Kenny Excel Discussion (Misc queries) 1 October 14th 07 03:09 AM
Specifying a Command Button on a worksheet as differentiated from one on a UserForm Amber_D_Laws[_52_] Excel Programming 14 February 7th 06 03:43 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Userform disappears when you try to initialize from a command button RPIJG[_60_] Excel Programming 8 July 2nd 04 08:14 PM


All times are GMT +1. The time now is 12:47 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"