VBA Lesson 24: Forms (Userforms) in VBA for Excel
The form is used to require information from the user to feed the VBA procedure. Different basic controls can be added to the userform they are called: labels, text boxes, combo boxes, list boxes, check boxes, option buttons, frames, command buttons, spin buttons and images . To learn more about all the controls see lessons 26 to 33.
Creating a Userform in Excel
Userforms are created in the Project Window of the Visual Basic Editor. You will also find the toolbox that allows you to add controls to your userforms in the Visual Basic Editor.
In the Visual Basic Editor you right click in the project window and you will see this menu appear:
Go to "Insert" and select "UserForm". You will then see the following:
On the right you see the userform that you have just added to your workbook. On the left is the toolbox with all the controls that you can add to your userform. You can hide that toolbox by clicking on the "X" and bring it back by clicking on the toolbox icon or by going to the menu bar "View/Toolbox". We will use the toolbox later in this section.
We hope you have enjoyed this introduction to lesson 24
All the Lessons
Lesson 1: Visual Basic Editor (VBE) in Excel, Lesson 2: The Project Window in the Visual Basic Editor of Excel, Lesson 3: The Properties Window in the Visual Basic Editor of Excel, Lesson 4: The Code Window in the Visual Basic Editor of Excel, Lesson 5: Developing Macros in the VBE, Lesson 6: Testing Macros in the VBE, Lesson 7: Excel Macro Recorder, Lesson 8: Macros Help and Assistance, Lesson 9: VBA Events, Lesson 10: VBA Security and Protection, Lesson 11: VBA Coding Tips, Lesson 12: Dealing with Errors, Lesson 13: Working with the Application, Lesson 14: Working with the Workbooks, Lesson 15: Working with the Worksheets, Lesson 16: Moving Around the Worksheet, Lesson 17: Working with Message and Input Boxes, Lesson 18: Excel VBA Vocabulary to Filter and Sort Data. Lesson 19: Working with Variables, Lesson 20: Working with Statements, Lesson 21: Working with Functions, Lesson 22: Working with external data and SQL, Lesson 23: Working with Windows and other Microsoft Programs FROM Excel, Lesson 24: Forms (Userforms) in VBA for Excel, Lesson 25: Userforms Properties and VBA Code, Lesson 26: Properties and VBA code for Command Buttons, Lesson 27: Properties and VBA code for Labels, Lesson 28: Properties and VBA code for Text Boxes, Lesson 29: Properties and VBA code for Combo Boxes, Lesson 30: Properties and VBA code for List Boxes, Lesson 31: Properties and VBA code for Check Boxes, Option Buttons and Frames, Lesson 32: Properties and VBA code for Spin Buttons, Lesson 33: Excel Image Controls
This website and the downloadable Tutorial on Excel Macros are divided in three sections:
Section 1: Excel Macros Programming: Lessons 1 to 10
Section 2: Excel VBA Vocabulary: Lessons 11 to 23
Section 3: Forms and Controls in VBA for Excel: Lessons 24 to 33