Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping procedure calls userform; how to exit loop (via userform button)? | Excel Programming | |||
Userform button | Excel Programming | |||
Use the X button on a userform | Excel Discussion (Misc queries) | |||
The userform X button | Excel Programming | |||
UserForm Button Help | Excel Programming |