so now I konw how to create a command button, I need to figure out how I can make that command button open a user form when I click it
so now I konw how to create a command button, I need to figure out how I can make that command button open a user form when I click it
Hello slmi1313,
First, you need to create a macro to open the UserForm, and then attach the macro to your button.
Macro Code to Display a UserForm
Replace UserForm1 with the name of your UserForm.Please Login or Register to view this content.
Adding the Macro
1. Copy the macro above pressing the keys CTRL+C
2. Open your workbook
3. Press the keys ALT+F11 to open the Visual Basic Editor
4. Press the keys ALT+I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL+V
7. Make any custom changes to the macro if needed at this time
8. Save the Macro by pressing the keys CTRL+S
9. Press the keys ALT+Q to exit the Editor, and return to Excel.
Right Click your command button and select Assign Macro.... Double Click on ShowForm.
Sincerely,
Leith Ross
when I right click my command button I do not have the option to assign macro... what am I doing wrong
Hello slmi1313,
Since you didn't say which type of command button you were using, I gave you directions for the Forms type, the most common type. If you can't assign a macro to the button then you must be using a Control Toolbox command button. You will have have to place a call to the macro in the button's Click event procedure.
Installing the Macro Event CodePlease Login or Register to view this content.
1) Open the workbook and Right Click the command button.
2) Select View Code
3) Type in ShowForm
4) Save the changes using CTRL+S
Sincerely,
Leith Ross
How about if I create the command button in excel sheet 1 using the control toolbox, and I want the command button to open sheet 2 what would be the code for that.
thanks
like I said Im pretty new to excel
Hello slmi1313,
Will say your Control Toolbox command button is named CommandButton1 on Sheet1. Copy and add the code below to the command button and it will activate Sheet2.
Sincerely,Please Login or Register to view this content.
Leith Ross
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks