LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default OK Button in UserForm

I have placed a commandbutton (the system appropriately named it
CommandButton1) on Sheet 1. When clicked it brings up UserForm1. In the
UserForm I placed another CommandButton which the system appropriately named
CommandButton2. I added the following code in the editor:
"Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Private Sub CommandButton2_Click()
UserForm1.Hide
End Sub"

It works fine. When you click the button on Sheet 1 it opens the UserForm.
Then when you are done referring to the form you click the commanbutton on
the form (appropriately labeled by me as OK) and the UserForm closes.

The problem is when I start repeating this for 10 more buttons on sheet 1
and 10 more userforms all to react the same way. The code for the first 2
look like this:
"
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Private Sub CommandButton2_Click()
UserForm1.Hide
End Sub

Private Sub CommandButton3_Click()
UserForm2.Show
End Sub

Private Sub CommandButton4_Click()
UserForm2.Hide
End Sub"

The problem: the first button and form work fine. The second and subsequent
buttons/forms display but do not go away when the form button is pushed only
when the Cancel (Red X) is pushed.

How can I get "all" the form buttons to close the form window as the first
one does?

Thanks Jack
 
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
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Userform button Greg B[_5_] Excel Programming 2 May 18th 05 11:28 AM
Use the X button on a userform Greg B Excel Discussion (Misc queries) 3 May 16th 05 09:19 AM
The userform X button Esben[_6_] Excel Programming 2 June 3rd 04 03:11 PM
UserForm Button Help meflorence Excel Programming 2 March 2nd 04 05:35 PM


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