![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
I hear everyone talk about how great a userform is. How (in simple terms) do I make one?
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Quite simple, once you've got the hang of it. Here's a quick guide:-
Open the VB Editor (Alt+F11) and choose Insert, Userform. This will create a blank userform which you can add controls to. Make sure the Toolbox is visible (View, Toolbox) and then click the Textbox control (the one with ab| on it) and then click the userform. This will add a textbox to your userform. Then do the same with the command control (the grey rectangle). Double click the command button. This should create a blank procedure for CommandButton1_Click. Type this:- Private Sub CommandButton1_Click() MsgBox "The text entered in the textbox was " & Me.TextBox1.Text End Sub Now press F5 (run), type something in the textbox and press the command button. You should see a message telling you what you typed into the textbox. Congratulations! You've created a userform! You can show the userform from a macro by doing this:- Sub Test() Userform1.Show End Sub HTH, D [ This Message was edited by: dk on 2002-03-08 11:38 ] |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
To create one, open up the VBA editor by pressing Alt-F11. You'll see a code window on the right and the Project Explorer window on the left with the names of your worksheets and an entry of ThisWorkbook.
Click on Insert and UserForm, this puts up a blank form and opens up the userform toolbox (if you lose the toolbox, either click on View- Toolbox or click the little hammer icon at the top). You can now 'draw' controls onto the UserForm. Depending on what you want to do, you may have a textbox for people to enter stuff, a listbox that they can pick options from, command buttons to exit the form or start another process running etc. Once you've drawn your contols on there right-click on any of them and select properties, you can then change thrie appearance etc. Press F5 to run the form. Now all you have to do is decide what you want to do with it! |
|
|
|
|
|
#4 |
|
Guest
Posts: n/a
|
Thanks. Learned a LOT today!
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Posts: 7,743
|
So did I!!!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|