Introduction of Userform VBA Easily

Welcome to Excel Avon

Introduction Of UserForm

DOWNLOAD USED EXCEL FILE FROM HERE>>

In today’s post we will Introduce UserForm. UserForm is like a wizard box or a dialog box in which we ask users to input data, and it contains some instructions. In Excel VBA, we have a very useful tool known as UserForm. This is a practical way of getting information from the user. VBA User Form is also inbuilt in excel and can be created by the developers. 

UserForm is like an object within the Excel interface. Inside this UserForm, we can create other useful wizard box or dialog boxes to get the data from the user.

Introduction Of UserForm In VBA

How to Create Userform in Excel VBA?

Well, you must know how to insert a module, it is just like that, because till now we were working with the module, let’s understand. So, we have to go like last time, first go to the Developer Tab then click on the option of Visual Basic as shown in the image below.

sort-data-on-excel-using-VBA

On opening in VBE, you have to go to Insert and then UserForm has to be inserted, as can be seen in the image.

introduction-of-userform

When we click on the User form, a separate wizard box will be created in a window VBE, in which you can see UserForm1 as the default name. You can increase or decrease the size of the Userform with the mouse pointer.

introduction-of-userform.png

If you have to make some changes in the Wizard box, then you have to go to the properties window which is like the bottom left, you can edit the form from here.

introduction-of-userform3

Now let’s make some changes like first of all we will change the name and caption of the UserForm1.

 introduction-of-userform4

introduction-of-userform5

Now let us try to change the color of the UserForm. In the property’s toolbox, we have a dropdown provided to us named as back color; we can select any set of colors we want.

introduction-of-userform6

After I select the option of back color, we will run the code, we can see the color of the form which is something like this see image below.

introduction-of-userform6 (2)

Now we will add label and text box in Form, first you have to go to tool, then in tool box you will see second option of label, you have to add it, Hover the mouse on Form and click and drag to insert a label in the Form., similarly again you have to select label then text The second option will be created for the text box, you have to add the text box, then you will create a text box similar to the label. You can see the image you can understand how to do it.

introduction-of-userform6 (3)

Now we want to change the color of the text of the label, so now we will go to the properties option and then go to ForeColor.

introduction-of-userform6 (3).png

By going to forecolor, you will click the down arrow, then you will get palette and system two categories, we will select palette color. Here we will select any one color which will change the label text.

introduction-of-userform6 (5)

After selecting the color, we will run the code.

introduction-of-userform6 (6)1 

After running the code, you will see Form like this, you can see the color of the text of the label, we have selected yellow color for Lebel of the text.

We can increase or decrease the height of the UserForm according to your own by going into. You will go to the height option and write the digit height you want.

introduction-of-userform6 (8)

We filled 350 in height and here you can see that UserForm’s height has increased.

introduction-of-userform6 (110

Now we will add scrollbar in UserForm which is in properties you can add any way like horizontal, vertical, or both together.

introduction-of-userform6 (100

After this we will run the code, you can see here both scroll bars have been added.

introduction-of-userform6 (155

After this we will change the mouse pointer of the UserForm, let’s do it. You can select any one from the list

introduction-of-userform6 (15454

As you can see in the image the mouse pointer has changed.

 

Now we will insert picture in UserForm. We will go to picture option then select a picture from the file.

introduction-of-userform6 (15)

After this we will run the code, it will open us the UserForm in the excel sheet and there you can see that the picture has been inserted.

introduction-of-userform6 (16)

The picture has been inserted but you can see that the picture is not fit in the Form. So now we will also fit the picture in the user form. We will go to PictureSizeMode option to fit the picture. here we select PictureSizeModeStretch.

introduction-of-userform6 (16).png

We will select PictureSizeModeStretch to fit the picture and then run the code so that we will get the size of the picture of the Form. PictureSizeModeStretch will be beneficial if you increase or decrease the size of the user form, the picture will remain fit. In PictureSizeMode you will get some more options like PictureSizeModeZoom Enlarges the picture but does not distort the picture in either the horizontal or vertical direction.

introduction-of-userform6 (18)

When a Form is modal, the user must provide information or close the UserForm before any other part of the application can be used. No subsequent code is executed until the UserForm is closed. For this we use the show modal option which when true (Default) The Form is modal. But if we make it false then we The Form is ModelLess. When these become false, then only we will be able to work behind the Form or in the sheet. so, we make it false.

introduction-of-userform6 (19)

After doing false we will run it as you can we can also write in the sheet. As we have also written it in the sheet after the form.

introduction-of-userform6 (20)

Therefore, I hope that you have understood this article of ours very well, maybe if you do not understand some options, then you can comment us, which we will answer soon and for more information, you can follow us on Twitter, Instagram, LinkedIn and you can also follow on YouTube.

DOWNLOAD USED EXCEL FILE FROM HERE>>

LEARN MORE TOPIC IN VBA HERE

You can also see well-explained video here about Introduction of UserForm Excel VBA

Leave a Reply