|
Home > Format > Tips > Text Box Excel Text Box FormattingHelp users by showing instructions in a worksheet Text Box. Manually change the text box settings, or use VBA to format the text box and resize it quickly |
If you create a workbook that other people will use, you can help them get started, by showing instructions in a TextBox.
You can adjust the size of the Text Box, by dragging the handles,
to ensure that all the text is visible. ![]()
To see the steps for adding a Text Box, and resizing it automatically, you can watch this short Excel video tutorial.
There are written instructions below the video, and a full transcript at the end of the page.
Video Timeline
To insert a Text Box on an Excel worksheet, follow these steps
After you add a Text box to the worksheet, you can adjust its size, if needed. For example, if you add more text to the existing message, the text box might be too small to show all of the text.
To manually adjust the text box size, follow these steps:
Note: If you drag on a corner handle, the size will adjust in two directions - height and width

When I'm adding instructions to a worksheet, I often add bullets, to make the notes easier to read. This short video shows how to add them to a text box, or in a cell.
In a Text Box, it's easy to add bullets to a list -- right-click on the text, and click Bullets, in the popup menu.
To quickly add a bullet to a cell, press Alt + 7 (on the number keypad)
Instead of manually adjusting the Text Box size, you can change a setting, to have it resize automatically.

The TextBox will now adjust its size automatically, if you add or remove text, or change the font size.

Note: If you adjust the TextBox by dragging the top or bottom
handle, the Resize Shape to Fit Text setting is automatically turned
off. ![]()

If your Excel 2010 (or later version) workbook contains several shapes, you can use this macro to turn ON the Resize Shape to Fit Text and Word Wrap setting for all of them.
Note: Textboxes, and other shapes with text, such as Rectangles, will also be affected.
Copy the VBA code below, and paste it into a regular module window in your workbook.
Warning: After you add the code to your workbook, be sure to save the file again, in macro-enabled workbook format. Otherwise, Excel will delete all the code from the workbook, when you close it.![]()
Sub TextBoxResizeAll()
Dim sh As Shape
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each sh In ws.Shapes
With sh.TextFrame2
.AutoSize = msoAutoSizeShapeToFitText
.WordWrap = True
End With
Next sh
Next ws
End Sub
You can use this macro to turn OFF the Resize Shape to Fit Text setting for all shapes in the active Excel 2010 (or later version) workbook.
This line of code is different from the code above, and turns off the AutoSize setting:
Note: Textboxes, and other shapes with text, such as Rectangles,
will also be affected. ![]()
Sub TextBoxResizeOFF()
Dim sh As Shape
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each sh In ws.Shapes
With sh.TextFrame2
.AutoSize = msoAutoSizeNone
.WordWrap = True
End With
Next sh
Next ws
End Sub
You can use this macro to turn OFF the Resize Shape to Fit
Text setting for all TextBoxes in the active Excel 2010 workbook.
![]()
Sub TextBoxResizeTB()
Dim sh As Shape
Dim ws As Worksheet
Dim lType As Long
lType = 17 'TextBox
For Each ws In ActiveWorkbook.Worksheets
For Each sh In ws.Shapes
If sh.Type = lType Then
With sh.TextFrame2
.AutoSize = msoAutoSizeShapeToFitText
.WordWrap = True
End With
End If
Next sh
Next ws
End Sub
Here is the full transcript for the video at the top of this page.
If you're creating a workbook for other people to use in Excel, you can add a text box with instructions to help them get started
If you adjust the size, the text wraps automatically, to show a little bit less on each line, and fill that text box
But if the text box gets too small, some of the text might be chopped off, and they might not see some crucial information, that is lower down in that text box
If I want to make sure that all the text shows up, I can set the text box to resize automatically
With the text box selected:
Everything is visible now, and if I add more text, the box would expand automatically to fit
But we've lost the Wrap Text
I could add some line breaks of my own, but that's the only workaround, using Excel 2007
If you're using Excel 2010 (or later), there's a wrap text feature that's been added
Here we have Excel 2010 open, and a text box sitting on the worksheet. We can see that it's chopped off at the end. Some of the text isn't visible
And it didn't widen that text box, so that will all fit across
If I drag a corner handle, it keeps the width that I adjusted to, but makes it tall enough to fit all the text
If I change the font size, it gets taller, to fit everything
So you can adjust with the width handle, or the corner handle
However, if you drag the bottom or top handles, that turns off the Auto Sizing
So now that we've done that:
If you have a workbook with lots of Text Boxes, that you want to change these settings on, you could use a macro.
I've created one that we can see here in Visual Basic
It has a variable for shape, and worksheet, and then it:
I'll just click in here, and click the Run button
Now each text box, or each shape that has text in it, like this rectangle, would have that setting changed
Excel Macro Worksheet Macro Buttons
Record and Test an Excel Macro
Excel Macro -- Adding Code to a Workbook
Last updated: September 18, 2024 10:07 AM