Be the first user to complete this post
|
Add to List |
VBA-Excel: User Forms
User Forms are one of the very important features in Excel Macro. It provides and an interface to the user for interaction with the workbook. It has many controls which makes user’s life easy for entering the data from excel in a specific manner or reading the particular data from the excel.
Getting Started : Create a Blank User Form
- To open or create a new user form, follow the steps below
- Open an Excel file
- Press “Alt+F11” to open the Microsoft Visual Basic Editor.
- Make Project Explorer and Property Window visible from “view menu” (If not already visible)
- Select the Project from the Project Explorer.
- Form “Insert” menu, select “User Form”
- Select the Userform1
- Go to the Property Window,
- Change the Name Property to “FirstForm”
- Change the Caption Property to “My First User Form”
16. Add Controls to the User form
- Select the control from the Tool Box and place it in the User Form.( here Command Button is selected)
- Select or Single Click on the Command Button from the Tool Box.
- Now Click on the UserForm, a new CommandButton will be created.
Private Sub FirstButton_Click()
MsgBox "Yeaaaahhhhh , I got Clicked"
End Sub
NOTE : To Navigate Between “Code Window” and “UserForm Design Window” KeyBorad Shortcut is [Control]+[Tab]
17. Now your User Form is ready to run. All you have to do is assign this User Form to a macro.
Macro to Open the UserForm
- Select the VBA Project from Project Explorer
- Form “Insert” menu, select “Module”
FirstForm.Show
End Sub
Also Read:
- VBA-Excel : 3D-Ranges – FillAcrossSheets Method
- VBA-Excel: Copy/Paste data - Copy the Entire row data and paste it to another row
- VBA Excel – Looping Through a Range of Cells
- VBA Excel – Refer to Multiple Ranges : Union Method
- Excel Macro - Visual Basic Editor