An Excel UserForm label is a control that displays text on a VBA form, such as an instruction, field name, or status message. To add one in desktop Excel for Windows, open the Visual Basic Editor, choose Insert > UserForm, select Label from the Toolbox, and draw it on the form; set its Caption property to the text you want readers to see.
What an Excel UserForm Label Does
A Label control presents information; it is not a place for the user to type or edit text. On a data-entry form, for example, a label reading “Email address” can sit beside a TextBox where someone enters an address. Labels can also show directions, warnings, section headings, or a brief result such as “Ready” or “3 records loaded.”
A UserForm is a custom dialog window created with Visual Basic for Applications (VBA). Its controls—such as labels, text boxes, buttons, and list boxes—provide a simple interface for a workbook task. A label is one of the basic controls in that group. It is separate from a worksheet cell, a chart title, and a text box inserted on a worksheet, even though all of them can display text.
Labels are useful when the form needs clear explanations without making the user interact with every piece of text. They can also be updated while the form is open, so a label that starts with “Ready” could later show a result or explain why an action is unavailable.
Adding a Label to a UserForm
In Excel for Microsoft 365 on Windows, first make the Developer tab visible if it is missing: choose File > Options > Customize Ribbon, then select Developer. Choose Developer > Visual Basic to open the Visual Basic Editor. In that editor, choose Insert > UserForm. The Toolbox normally appears with the new form; if it does not, choose View > Toolbox.
- Select the Label control in the Toolbox. Hover over a Toolbox icon to see its name if you are unsure which one it is.
- Click or drag on the UserForm to place the label. Dragging lets you set an approximate width and height.
- Select the label and open the Properties window, usually with View > Properties. Set its (Name) property to a meaningful identifier, such as
lblStatus, and set Caption to the visible text. - Use the form designer to position and resize the label. Open the form from VBA to check how it looks at run time.
The control name and its caption serve different purposes. VBA code refers to the name, while the user sees the caption. Keeping a name such as lblInstructions and a caption such as “Choose a department” makes both the design and the code easier to understand.
Important Label Properties
With a label selected in the form designer, its Properties window controls its behavior and appearance. The most commonly used properties include:
- (Name): The identifier used in VBA, for example
lblStatus. Names should be unique among controls on the form and should not contain spaces. - Caption: The displayed text. This can be a short word, a sentence, or a value changed by code.
- Font: The typeface, size, and emphasis used for the text. A larger or bold font can establish a visual heading, but too many styles make a form harder to scan.
- ForeColor and BackColor: The text and background colors. A label’s background may be transparent or opaque, depending on its BackStyle setting.
- TextAlign: The alignment of the caption within the label, typically left, center, or right.
- WordWrap and AutoSize: These affect how the control handles text that does not fit. Wrapping can place text on multiple lines; AutoSize can resize the control to fit its contents. Check the resulting form rather than assuming the designer dimensions will remain unchanged.
- Visible and Enabled: Visible controls whether the label is shown. Enabled affects whether it is active; labels are generally informational, so disabling one is not a substitute for hiding it.
Other properties, including Height, Width, Left, and Top, determine the label’s size and location in relation to the form. For a label used as a warning or status, check the contrast and make sure the text remains readable at the form’s actual size.
Changing a Label with VBA
To change a label after a form opens, set its Caption property in an event procedure. For example, if a label is named lblStatus, this form initialization event gives it an initial message:
Private Sub UserForm_Initialize()
' Set the label text when the form opens.
Me.lblStatus.Caption = "Ready"
End Sub
You can also update a label in response to a button click. The following example assumes the form contains a label named lblStatus and a CommandButton named cmdShowTotal:
Private Sub cmdShowTotal_Click()
Dim itemCount As Long
' Example result for a task that found three records.
itemCount = 3
Me.lblStatus.Caption = "Loaded " & itemCount & " records."
End Sub
The example displays “Loaded 3 records.” Replace the illustrative value with a count or message produced by your own procedure. Me refers to the UserForm containing the event code, and the dot notation accesses a control on that form. If the name in the code does not match the control’s (Name) property, VBA will not find the intended control.
To add or edit an event procedure, double-click the relevant control in the form designer or select the form or control in the code window’s object and procedure lists. For a label’s initial text, UserForm_Initialize is usually a natural place; for a status that changes after an operation, update Caption in the procedure that performs that operation.
Layout and Readability
Labels often work best when they make the form’s structure obvious. Put a short field label next to the control it describes, align related labels consistently, and leave enough space between unrelated groups. A label that says “Enter the date the report starts from” may need more width or multiple lines, whereas a concise “Start date” can fit in a narrow column.
When a caption is clipped, first consider whether the control is too small or the text is unnecessarily long. Widening the label, enabling WordWrap, or shortening the wording may solve the problem. If you enable AutoSize, review the positions of nearby controls: a label that grows can overlap another control or disrupt a carefully aligned layout. For a multi-line instruction, set the label’s dimensions deliberately and check how the text wraps at run time.
Use color and font changes with a purpose. A red label can draw attention to an error, but color alone should not communicate essential meaning; include explicit text such as “Error: select a department.” Labels should also have enough contrast against their background. A form that will be used on different computers should be checked at its intended display size, because font rendering and available fonts can vary.
Label Compared with a TextBox or Worksheet Text
A Label and a TextBox may look similar, but they have different jobs. Use a Label to show text that the user is not expected to edit. Use a TextBox when the user must enter or change a value, such as a name or search term. If users need to copy a long result or edit it, a TextBox configured appropriately may be a better choice than a label.
A worksheet cell is better when the information belongs in the worksheet grid, needs to be referenced by formulas, or should remain visible without opening a dialog. A worksheet text box or shape is useful for on-sheet instructions and dashboard annotations. A UserForm label is appropriate when the message belongs inside a VBA-driven form and should appear as part of that form’s interface.
One common misconception is that a label automatically displays a worksheet value because its caption resembles a cell address. It does not: VBA must assign the value, or another design mechanism must supply it. For instance, code can read a cell and set Caption, but the label itself is not a worksheet formula cell.
Common Problems and Fixes
- The caption is cut off: Increase the label width or height, shorten the wording, or review WordWrap and AutoSize. Check the label in the running form, not only in the designer.
- Code reports an unknown member or control: Confirm that the label’s (Name) property exactly matches the identifier used in code. The visible Caption does not determine the VBA name.
- The label shows old text: Search the form’s event procedures for another assignment to Caption. A later procedure may overwrite the text set during initialization.
- A label appears over another control: Adjust Left, Top, Width, or Height in the designer. Also check whether AutoSize changes its dimensions when the form opens.
- Nothing runs when a button is clicked: Verify that the code is in the button’s Click event and that the button’s (Name) matches the event procedure. A label is normally informational; it is not a substitute for a button when the user needs to trigger an action.
Before running VBA that changes a workbook, save a copy of the file. Macros cannot be undone with Ctrl+Z, so a backup is useful if the code changes data or other workbook content. A simple label-text update is low risk, but it is still sensible to test new event code on a copy, especially when it is part of a larger procedure.
Excel Version and Platform Notes
VBA UserForms are a desktop Excel feature, not a way to create an interactive form in Excel for the web. A workbook containing VBA can be stored or viewed online, but the web app does not run VBA macros; users need a compatible desktop version to open and use a VBA-driven form.
Excel for Mac has VBA support, but the available controls and their behavior can differ from Windows. In particular, do not assume a form built with Windows-only ActiveX controls will work on a Mac. If a workbook will be shared across Windows and Mac, keep the form design conservative and test the actual workbook on each target platform. Ribbon and editor details may also differ by Excel release; the steps above describe Microsoft 365 for Windows.
Frequently Asked Questions
How do I change the text on an Excel UserForm label?
In the designer, select the label and edit its Caption property. While the form is running, assign a new string to the label’s Caption property in VBA.
Can a UserForm label display a cell’s value?
Yes, but the label does not link to a cell automatically. VBA must read the cell value and assign it to the label’s Caption, or you must use another suitable approach in the form.
Can users type into a label?
No. A Label displays information rather than accepting text entry. Use a TextBox when the user needs to type or edit a value.
Why can’t I see the Toolbox in the Visual Basic Editor?
Select the UserForm in the editor and choose View > Toolbox. The Toolbox is used to add controls such as labels and text boxes to the form.
Do Excel UserForm labels work in Excel for the web?
No. Excel for the web does not run VBA UserForms. Open the workbook in a desktop version of Excel that supports the workbook’s VBA features.
Related
- Power Query Text to Columns: Split Data Step by Step
- Data Validation Framework: Design, Rules, and Examples
- What Is Power Query? Excel Data Cleanup Explained
Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.
More in VBA & macros
- Excel VBA Sort Method of Range Class Failed: Fixes“Sort method of Range class failed” is usually Excel’s run-time error 1004: a VBA sort request could not…
- Sort Columns in Excel with VBAYes. In Excel VBA, use the Sort object to sort entire rows by values in a chosen column,…
- Excel VBA: How to Use Not IsErrorIn Excel VBA, write If Not IsError(value) Then to test whether a value is not an Excel error…
- Excel VBA MsgBox 3 Buttons: Options, Results, and ExamplesTo show three buttons in an Excel VBA message box, use a built-in button-set constant such as vbYesNoCancel…
- VBA Range.Intersect: Find Overlapping CellsIn VBA, use Application.Intersect(range1, range2) to find the cells shared by two or more ranges. It returns a…
- Excel Macro MsgBox Syntax: Buttons, Results, and ExamplesIn Excel VBA, the basic MsgBox syntax is MsgBox(prompt, [buttons], [title], [helpfile], [context]). For a simple message, call…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.