Excel VBA UserForm
Excel VBA Tutorial No. 3
In tutorial number 2 we learned how to add developer tab in Excel and also how to open VBA window. In this basic tutorial today, we will learn that,
- How to Add Userform in Excel VBA?
- How to change color text font name? How to change the format of the user form?
- Overview of Visual Basic Applications window
By clicking on Visual Basic option in the Developer Tab, or by pressing Alt+11, the window of Visual Basic for Application will open. The top menu bar will appear. These options are used to manage the project.
File – With this option, the user can export and save the form. And you can insert the saved form in any file. The option to delete or print the user form is also found in it.
Edit – In this option, options like undo redo copy cut paste delete select find replacement will be found.
View – With this option you can see the code object or any hidden window on the screen.
Format – This option is used for formatting the selected object.
Debug – With this option you can check coding steps and linking. The option of debug proves to be very suitable for a programmer. If an error occurs while coding, then it is very easy to search through debug.
Run – This option is used to test the specific code of the project. The run option causes the project to run live.
Tools – All the macros you have created in the tools will be visible. Also, some limited tools are provided in the tool box. To add additional tools, one has to add through the Tools option. To protect the project, you can protect it from the Properties option in Tools.
Tool Bar – Quick tool bar is given below the menu bar. You can use this option easily. The sheet code in the project explorer contains the code model and user form of the workbook.
To view the code- you can view the code by double clicking or right clicking the object. The code of the selected object will appear in the editor pane. And the Properties window of the selected object will also appear below on the left side. You can move and resize all windows by dragging.
1. How to add a user form to Excel?
By clicking on the Insert option in the menu bar, click on the user form in the drop down of the insert. The user form will be added.
Userform1 The first user form by this name will be created by default. All the users who add the form will be added to the list of form options in the project explorer window. In that list, you will see the form on which you double click on the editor pane. To see the code of the form, right click on the name and the view code will show all the codes associated with the form selected with this option.
2. How to change name color text font of Userform excel vba ?
Excel VBA UserForm Properties
All the options will be found in the Properties window to change the format of the form. Know some important options.
Name – You can give any name to the form. Use the under score instead of the space in the text while naming the file. For example, if you want to name Master Data, give Master_Data as follows.
Back Color – The back color of the entire form can be changed with this option. Clicking drop down will show two lists. system and palette.
Caption – Whatever text you write in it will appear in the top of the user form.
Enable – Users can lock the activity of the form by selecting false. You can unlock with the true option.
Picture – To insert a picture in the user form, click in front of the picture option and click on the 3 dots. Select a picture from the location and upload it. You can set the photo in the user form with the option of picture size and alignment under the picture option.
Delete picture from user form – click in front of the picture option of properties and press the delete button on the keyboard. The picture of the user form will be deleted.
This is an option for some important Excel userform properties. Similarly, you can change the properties of all tools. Depending on the tool, a little change occurs in the properties.
In Next tutorial we will learn about how to add label, text box, button, combo box, list box and radio button in user form. Video series will also be available for you soon.