Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 61
Default User form Command Buttons

Does anybody now how to code a button in a user form to not work until the
other buttons are clicked. for example i have 3 buttons one "OK" one "next"
one "close". I would like the user to click the ok button then the next,
then the close when theu are done. any help would be appreciated.

Thank you

J
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default User form Command Buttons

By toggling the enabled property of the command buttons you can control the
flow. Something like this. buttons 2 and 3 are disabled at start up. When
button 1 is pressed button 2 is enabled. When button 2 is pressed button 3 is
enabled.

Private Sub CommandButton1_Click()
CommandButton2.Enabled = True
End Sub

Private Sub CommandButton2_Click()
CommandButton3.Enabled = True

End Sub

Private Sub UserForm_Initialize()
CommandButton1.Enabled = True
CommandButton2.Enabled = False
CommandButton3.Enabled = False
End Sub

--
HTH...

Jim Thomlinson


"jhyatt" wrote:

Does anybody now how to code a button in a user form to not work until the
other buttons are clicked. for example i have 3 buttons one "OK" one "next"
one "close". I would like the user to click the ok button then the next,
then the close when theu are done. any help would be appreciated.

Thank you

J

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 638
Default User form Command Buttons

Jim has provided a nice solution. If you have to have the buttons
enabled all the time you could do this:
You can hide a couple text boxes on your form with visible set to
false. On the UserForm Initialize, set the text boxes = to 0. On the
Click Events of each of the buttons, place some code to change the
textbox to 1. Then, on the Click Event of the Close button, place
some code to check to make sure that the value in both of those fields
is 1. If it's not, then one or both of the buttons haven't been
clicked.

UserForm Initialize
txtNext.Text=0
txtOK.Text=0

Click Even of Next button
Me.txtNext.Text = 1

Click Even of OK button
Me.txtOK.Text = 1

Click Event of Close button
If Me.txtNext=0 Or Me.txtOK.Text=0 then
Msgbox "Not Clicked"
Exit Sub
Else
'continue code
End If

jhyatt wrote:
Does anybody now how to code a button in a user form to not work until the
other buttons are clicked. for example i have 3 buttons one "OK" one "next"
one "close". I would like the user to click the ok button then the next,
then the close when theu are done. any help would be appreciated.

Thank you

J


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 61
Default User form Command Buttons

Thank you worked great.

"Jim Thomlinson" wrote:

By toggling the enabled property of the command buttons you can control the
flow. Something like this. buttons 2 and 3 are disabled at start up. When
button 1 is pressed button 2 is enabled. When button 2 is pressed button 3 is
enabled.

Private Sub CommandButton1_Click()
CommandButton2.Enabled = True
End Sub

Private Sub CommandButton2_Click()
CommandButton3.Enabled = True

End Sub

Private Sub UserForm_Initialize()
CommandButton1.Enabled = True
CommandButton2.Enabled = False
CommandButton3.Enabled = False
End Sub

--
HTH...

Jim Thomlinson


"jhyatt" wrote:

Does anybody now how to code a button in a user form to not work until the
other buttons are clicked. for example i have 3 buttons one "OK" one "next"
one "close". I would like the user to click the ok button then the next,
then the close when theu are done. any help would be appreciated.

Thank you

J

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
Form buttons vs. ActiveX Buttons GeorgeJ Excel Discussion (Misc queries) 3 August 11th 07 09:02 PM
How do I fill a cell in a user form from a selection on same form? Terry Tipsy Excel Discussion (Misc queries) 4 June 11th 07 02:59 PM
User form and Command button Marilyn Excel Discussion (Misc queries) 3 May 9th 07 12:50 AM
Help with command buttons Danno Excel Worksheet Functions 1 October 7th 05 10:32 PM
Command Button on User form for Printing Anthony Slater Excel Discussion (Misc queries) 2 September 7th 05 02:01 PM


All times are GMT +1. The time now is 02:22 AM.

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

About Us

"It's about Microsoft Excel"