Want to become an expert in VBA? So this is the right place for you. This blog mainly focus on teaching how to apply Visual Basic for Microsoft Excel. So improve the functionality of your excel workbooks with the aid of this blog. Also ask any questions you have regarding MS Excel and applying VBA. We are happy to assist you.

How to Add Textboxes to VBA Userforms

In the last post I showed how to add labels to a VBA userform. Click on the link below to read that post.

How to add labels to VBA Userforms

In this post I will show you how to add textbox controls to a VBA userform. Textboxes are also a very important control type used in the user interfaces. It is the control type used to get free text input from the users. Therefore textboxes are also a widely used control type in VBA userforms.

So now let’s look at how to add textboxes to a form. Showing below is the form we created in our last post.

VBA Userform with only labels

To insert the textboxes, first we need to click on somewhere in the userform. When clicked on the userform, you should see the toolbox appear like this.

toolbox

If you can’t see the Toolbox, then click on the “View” menu and select “Toolbox”.

Click View menu

Select Toolbox

Next, click on the TextBox icon in the Toolbox.

Click on the TextBox icon

We have selected the TextBox control now.

TextBox control type is selected

So now we can create textboxes inside the userform. Take your mouse pointer to the Userform where you want to create the Textbox. You will notice that the shape of the mouse pointer has changed to something like this.

Change of mouse pointer

Left click on the mouse and drag it to form a small rectangle like below while pressing the left mouse button.

Click on the VBA form and create a rectangle shape

Release the left mouse button. A TextBox will be created like this.

Textbox created

Now we need five more textboxes for other labels.You can use the same steps above to create those other textboxes. Or else you can create five copies of the textbox you created. To create the copies, right click on the textbox and then select “Copy”.

Copy textbox

Then right click again and select paste.

Select paste

Do this pasting step consecutively for five times. Note that all the textboxes will be pasted in the same spot overlapping each other. Therefore you may won’t see five textboxes. So you can click on the textboxes and move each of them to where you want. Also you can use shortcut keys to Copy and Paste TextBoxes too. Use Ctrl + c to copy and Ctrl + v to paste. I moved the textboxes to infront of each label.

Userform with six Textboxes

And this is how the form would look like in the running mode.

Appearance of VBA userform in the running mode

Contact Form

Name

Email *

Message *