Excel UserForm TextBox: How to Wrap Text

VBA & macros · Updated November 18, 2026

To wrap text in an Excel UserForm TextBox, set its MultiLine property to True and its WordWrap property to True. In the Visual Basic Editor, select the TextBox and change those properties in the Properties window; you can also set them in VBA when the form opens.

What wrapping does in a UserForm TextBox

A UserForm TextBox is a control for displaying or entering text on a form created with Excel VBA. Its WordWrap setting determines whether a line of text continues on the next visual line when it reaches the control’s right edge. The setting is useful for notes, comments, descriptions, and other entries that may be longer than one line.

Wrapping is not the same as making a TextBox multiline. A single-line control cannot display several lines in the usual way, so set MultiLine to True as well. With both properties enabled, text can occupy multiple visual lines and long text can wrap within the control. Wrapping changes how text is displayed; it does not automatically enlarge the TextBox or add line-break characters to the text.

This is separate from the worksheet’s Wrap Text feature. A UserForm TextBox has its own properties, while a cell uses Excel’s cell-formatting options. Turning on Wrap Text for a worksheet cell does not change how a UserForm control behaves.

Set the properties in the Visual Basic Editor

  1. Open the workbook in desktop Excel and press Alt+F11 to open the Visual Basic Editor on Windows.
  2. In the Project Explorer, open the UserForm that contains the TextBox. If the Project Explorer is hidden, use View > Project Explorer.
  3. Select the TextBox on the form’s design surface. Check that you selected the TextBox itself, not the UserForm or a label beside it.
  4. Open the Properties window with F4 if it is not visible. Find MultiLine and set it to True, then find WordWrap and set it to True.
  5. Optionally set ScrollBars to 2 - fmScrollBarsVertical if users may enter more text than the control can show at once.

The properties take effect when the form runs. You can test the result by starting the form from the VBE, entering a sentence that is longer than the TextBox’s width, and checking whether it continues on a second line. On Excel for Mac, VBA and UserForms are available, but the editor’s menus and keyboard shortcuts can differ; use Tools > Macro > Visual Basic Editor to open the editor if needed, then use its View menu to show the Properties window.

Set wrapping with VBA when the form opens

You can also assign the properties in the form’s initialization event. This is useful when you want the setup to be explicit in code, or when form settings may be changed or rebuilt as part of a project. Replace TextBox1 with the actual name of your control. Put this procedure in that UserForm’s code module:

Private Sub UserForm_Initialize()
    Dim inputBox As MSForms.TextBox

    ' Configure the TextBox for wrapped, multiline entry.
    Set inputBox = Me.TextBox1
    inputBox.MultiLine = True
    inputBox.WordWrap = True
    inputBox.ScrollBars = fmScrollBarsVertical
    inputBox.EnterKeyBehavior = True
End Sub

The procedure runs as the form is initialized. MultiLine enables multiple lines, WordWrap wraps long lines at the control’s edge, and the vertical scrollbar lets a user move through text that does not fit in the visible area. EnterKeyBehavior makes Enter insert a line break in a multiline TextBox. If you prefer Enter to trigger the form’s default action, omit that assignment or leave the property set to False.

Before running any macro, save a copy of the workbook. VBA changes cannot be undone with Ctrl+Z. The example only changes control settings, but a backup is still a sensible precaution when editing a workbook project.

Choose the right multiline and Enter-key behavior

Whether Enter should create a new line depends on what the form is for. In a notes field, users usually expect Enter to start another line, so set EnterKeyBehavior to True. In a short field where Enter should submit the form or move the workflow forward, keeping it False may be more appropriate. Test this behavior with the form’s default button and other keyboard actions, because users may rely on Enter to finish an entry.

Text wrapping itself does not require a user to press Enter. For example, with a TextBox that is 200 points wide, a long sentence can flow onto further displayed lines automatically. A user-entered line break is different: it separates the text into paragraphs or lines even if the current line has not reached the edge. This distinction matters if the value will later be copied to a worksheet or processed by VBA.

If the entry is intended to be short, a single-line TextBox may be easier to use. If it can contain paragraphs, use a multiline control and consider a vertical scrollbar. A horizontal scrollbar is generally less helpful for prose because it requires users to scroll sideways to read a line; it may be useful for content such as long codes or paths that should not wrap.

Size the control and make long entries readable

Wrapping can only show as much text as the TextBox’s height allows. Increase the control’s height if users should see several lines while entering text. Also consider its width: a narrow control wraps sooner and produces more lines, while a wider one is easier to scan but may take up valuable space on the form. The font, font size, and the presence of a scrollbar affect how much text fits.

A scrollbar does not make the control larger; it gives access to content outside the visible area. For a notes field, a reasonable starting design is a multiline TextBox with WordWrap enabled, enough height for several lines, and a vertical scrollbar. The appropriate size depends on the form and the typical length of the expected entries. Avoid designing only around a short sample, because a user’s actual text may be much longer.

There is also a difference between a line that wraps on screen and a line break stored in the value. If a sentence wraps only because it reaches the TextBox edge, the displayed line break is a visual effect. If the user presses Enter with EnterKeyBehavior enabled, the value contains a line break. Code that counts lines, splits text, or writes it elsewhere should account for this difference rather than assuming each visible line is a separate paragraph.

Transfer the TextBox value to a worksheet

When you assign a multiline TextBox value to a worksheet cell, Excel can store the text, including line breaks entered by the user. The cell’s display is controlled separately. If the cell should show multiple lines, select it and use Home > Alignment > Wrap Text. You may also need to adjust the column width or row height; a cell can contain the full value even when its current dimensions do not show all of it.

For example, a form might collect a customer comment in TextBox1 and place it in cell B2 when the user clicks a Save button. Setting the TextBox’s WordWrap property does not set the worksheet cell’s Wrap Text format. Conversely, formatting B2 to wrap does not make text wrap while the user is typing in the form. Treat the input control and the destination cell as two separate display areas.

If the form is meant to preserve paragraphs, test a value containing both automatically wrapped text and a line break entered with Enter. Check the value after saving it to the cell, and check the cell after reopening the workbook. This simple check can reveal whether the form’s Enter-key behavior and the worksheet’s display formatting match what users need.

Common wrapping problems and fixes

  • The text stays on one line: Confirm that both MultiLine and WordWrap are set to True on the TextBox, not on a neighboring label or the form.
  • Text wraps but later lines are hidden: Increase the TextBox height or enable a vertical scrollbar. Word wrapping does not automatically resize the control.
  • Enter closes or submits the form: Set EnterKeyBehavior to True if Enter should insert a line break. Check whether a default button or other form logic handles Enter.
  • A worksheet cell does not show the same layout: Set Wrap Text on the destination cell separately and adjust row height or column width as needed.
  • A long string looks awkward: Test the actual kind of content users enter. Words, URLs, identifiers, and other unbroken strings may not behave like ordinary prose at a narrow control width.
  • The code reports that a control name is invalid: Select the TextBox in the designer and check its (Name) property. The control’s name is not necessarily the text shown in a label or its displayed value.

When troubleshooting, inspect the control’s properties in the designer before changing unrelated form code. If the properties are correct but the display still seems wrong, check the control’s dimensions, font, and scrollbar settings, then run the form again. A change made to one TextBox does not automatically apply to other TextBoxes on the same form.

Frequently Asked Questions

Does WordWrap work without MultiLine?

For normal wrapping across several displayed lines, set MultiLine to True as well as WordWrap. WordWrap controls how multiline text flows; it does not turn a single-line TextBox into a paragraph field by itself.

How do I make Enter create a new line in a UserForm TextBox?

Set MultiLine to True and EnterKeyBehavior to True. If Enter should instead activate a form action, leave EnterKeyBehavior off and provide another way to enter a line break if the field needs one.

Does wrapping change the text stored in the TextBox?

Automatic visual wrapping does not add a line-break character to the value. A line break deliberately entered by the user is part of the text. This matters when you copy the value to a cell or use VBA to count or process lines.

Can a UserForm TextBox automatically grow to fit its text?

Enabling WordWrap does not automatically increase the control’s height. Set a suitable height in the designer, use a scrollbar for longer entries, or write additional VBA to resize the control if that behavior is genuinely needed.

Why does the text wrap in the form but not in the worksheet?

The UserForm TextBox and the worksheet cell have independent formatting. Enable Wrap Text for the destination cell with Home > Alignment > Wrap Text, then check the cell’s row height and column width.

Related

Try it: the Column Letter to Number: aA is 27, XFD is 16,384. Converts both ways.

More in VBA & macros

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.