Pages

How to Format Label Text in VBA Forms (To Give Professional Look)

Labels are an inevitable control type used in VBA userforms. But when you create a label inside a form, default formatting of the labels are not appealing. So in this post I will show you how to change the formatting of the label text to get a more professional look. We can change various aspects of label text such as font type, font size and font style. Also few effects like underline are also available for label text. So now let’s look at how to change the text format of the labels. Let’s consider this sample userform.

Sample VBA userform

As you can see these labels don't have an appealing look in the running mode.

Initial form in running mode

I have 7 labels in this sample form. One for title and rest for the other fields. So I will apply two different text formats for these labels. I will add one format for the title label and a different format for the other six labels. To change the formatting of the text, first you need to select the label. So first let’s select the title label.

Select title label

Next go to the “Font” field of the “Properties” window.

Properties window

Click on the font field. Small grey color box with three dots will appear like this.

Select font field

Next, click on that box. “Font” window will appear like this.

Font window

Now you can change the type, style and size of fonts from this window. Also you can add two effects to the text. Those two effects are strikeout and underline effects. Furthermore a sample text is displayed alongside with these options. So the format of that sample text will change in realtime to give you an idea about the formatting of the final result.

For the title label, I will choose the following options.

Selected options for the title label

Also I will use capital letters for the title to give a better appearance. So the title label will look like this in the running mode.

Final result of title label

Next step is to apply a suitable format for the six other labels. As we are going to apply the same format for all the labels, we can select all of them and apply the format once. There are two ways to select multiple controls inside a VBA form. First method is clicking on each control while pressing down the Ctrl key. Or else you can left click on the suitable place in the form and drag the mouse while pressing down the left mouse button to form a rectangle. This rectangle should overlap with all the controls you want to select. Once all the required controls are covered by the rectangle release the left mouse button. So I will follow the second method in this example.

Drag to select labels

Six labels are selected

Now we can use the same steps to open the Font window like we did for the Title label. For these six labels, I will select the following options.

Selected font options for six labels

This is how the form looks like in the running mode.

Final form in the running mode