View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
JW[_2_] JW[_2_] is offline
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