A Text Box is a rectangular-shaped object in Excel that can hold and display texts within a specific area of a worksheet.
In this Excel tutorial, we are going to learn all the details related to the text box feature.
In the following image, we have a dataset containing sales of different accessories in different locations. Below that, there is a text box holding a summary of the dataset. It is displaying the highest and lowest sales.
Within this post, we will cover
- What is a text box?
- Different methods of adding a text box
- Formatting a text box
- Methods to copy and delete a text box
- Creating a dynamic and floating text box
- Adding hyperlinks to it
- Methods to link cells to a textbox
- Converting text boxes into cell values
- Applying conditional formatting to a text box
- Adding a text box on an Excel graph
- What to do when a text box doesn’t appear in a workbook?
We have used Excel for Microsoft 365 in this tutorial. You can apply the knowledge to Excel versions from 2007.
⏷ What Is a Text Box?
⏷ Add Text Box in Excel
⏷ Format Text Box in Excel
⏵ 1. Changing Shapes and Editing Points
⏵ 2. Changing Shape Styles
⏵ 3. Changing Fill Color of Text Boxes
⏵ 4. Removing the Border
⏵ 5. Changing Font Size, Style, and Color
⏵ 6. Changing Line Spacing Inside a Text Box
⏵ 7. Rotating the Text Box
⏵ 8. Resizing the Text Box to Fit Text
⏵ 9. Aligning Text Boxes in Excel
⏵ 10. Changing Transparency of a Text Box
⏵ 11. Anchoring Text Box in Excel
⏷ Copy a Text Box in Excel
⏷ Create Dynamic Text Box in Excel
⏷ Create Floating Text Box in Excel
⏷ Get Text Box Linked to a Cell in Excel
⏷ Add Hyperlinks to a Text Box in Excel
⏷ Apply Conditional Formatting to a Text Box in Excel
⏷ Convert Text Box Content into Cell Content in Excel
⏷ Add Text Box in Excel Graph
⏷ Delete a Text Box in Excel
⏷ What to Do When Text Box is Not Showing in Excel?
What Is a Text Box?
A text box is an object used in Microsoft Office applications. This is a graphic element that can hold text in a certain area. It allows us to display text without taking up cell content.
It helps direct attention to certain texts on a sheet. Other uses include:
- Adding textual information to content
- Adding comments, annotations, titles, etc.
- Helpful for moving around texts in a document
- Can provide interactive forms with functions like linking.
How to Add Text Box in Excel: 4 Suitable Ways
There are four ways to insert a text box in Excel: from the text options, from Shapes, using the Developer tab (for ActiveX Control), and VBA.
Let’s take a dataset containing the sales data of a company across different branches.
We want to add text boxes in this sheet to point out information such as sales of the highest or specific branch, summary, quotations, etc.
1. Using the Text Box Option
The Text Box object is available to add directly from the ribbon. Here is how you can do this:
- Go to the Insert tab and select Text Box from the Text group.
- You will notice the mouse cursor changing.
- Click it over the worksheet where you want to insert the text box and drag it towards the end.
- Now insert text inside the text box.
Using Keyboard:
You can achieve the same result using the keyboard keys Alt, N, X in order. It will create a text box on the worksheet. You can then resize and insert text inside of it to achieve the same result.
2. Adding Text Box from Shapes
The same feature is also available under the Shapes option. Here is how you can insert a Text Box in Excel from there:
- Go to Insert >> Illustrations >> Shapes.
- Select Text Box from Basic Shapes.
- The mouse cursor will change after that. Now click and drag over the text box area on the worksheet to get the text box.
- Finally, insert the text inside the text box.
3. Inserting Text Box from ActiveX Controls in Excel
The ActiveX Control text boxes provide more functionality and customization options than regular text boxes. Its usability comes in handy for:
- Creating interactive forms
- Creating data entry fields
- Displaying dynamic information
Follow the steps below to insert an ActiveX Control Text Box in Excel.
- First, you need to enable the Developer tab in the Ribbon.
- Go to Developer >> Controls >> Insert.
- Select the Text Box (ActiveX Controls) under ActiveX Controls.
- Now click and drag over the worksheet area to get the text box.
- The object is in design mode at this point for editing. To turn it off, click on Developer >> Controls >> Design Mode.
- Now you can insert the text inside the text box.
Adding a Multi-Line Text Box with Scrollbar
To create a Multi-Line Text Box with a Scrollbar, create an ActiveX Control text box first using the above method. Then right-click on the text box and select Properties from the context menu.
The Properties window will open. Select the True as MultiLine option and 1, 2, or 3 for ScrollBars depending on the type of scrollbar you want.
We have selected 2 because this option creates vertical scrollbars.
Now, you can insert your text. If it is long enough, you will see the scrollbars appearing on the text box.
4. Using VBA to Add Multiple Text Boxes in Excel
We sometimes need multiple text boxes to hold multiple pieces of information. For example, we can add three text boxes to point out the highest sales in three different categories.
In these cases, VBA comes in handy. You need to enable the Developer tab to use VBA too.
We are going to utilize this in the following way to create multiple text boxes.
- Go to Developer >> Code >> Visual Basic from the ribbon.
- Select Insert >> Module in the VBA window.
- Insert the following code in the module.
Sub InsertMultipleTextBoxes()
Dim ws As Worksheet
Dim textBox As Shape
Dim i As Integer
Dim numTextBoxes As Integer
Dim textArray() As String
' Set the worksheet where you want to insert the text boxes
Set ws = ThisWorkbook.Sheets("4.1 VBA Multiple Box") ' Replace "4.1 VBA Multiple Box" with your actual sheet name
' Set the number of text boxes you want to insert
numTextBoxes = 3 ' Change this to the desired number
' Array of different texts for each text box
textArray = Split("Sioux City has the highest television sales,Stony Brook has the highest mobile sales,Green Bay has the highest monitor sales", ",")
' Loop to insert multiple text boxes
For i = 1 To numTextBoxes
' Insert a text box
Set textBox = ws.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=50 + (i - 1) * 200, Top:=230, Width:=150, Height:=50)
' Set the text inside the text box
textBox.TextFrame.Characters.Text = textArray(i - 1)
textBox.TextEffect.FontSize = 12
textBox.Line.ForeColor.RGB = RGB(0, 0, 255)
Next i
End Sub
- Press F5 to run the code.
You can use the same code without a loop to create a single text box. The code is as follows.
Sub InsertTextBox()
Dim ws As Worksheet
Dim textBox As Shape
Set ws = ThisWorkbook.Sheets("4. VBA") ' Replace "4. VBA" with your actual sheet name
Set textBox = ws.Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
Left:=60, Top:=230, Width:=250, Height:=80)
textBox.TextFrame.Characters.Text = "Total Sales by Store:" & vbNewLine & "Green Bay has the highest total sales with $50,960, followed by Sioux City with $41,614." & vbNewLine & "Rock Island has the lowest total sales at $14,628."
textBox.Line.ForeColor.RGB = RGB(0, 0, 255)
End Sub
How to Format Text Box in Excel
There are many customization options even for basic text boxes in Excel. Some of them are discussed in this section.
1. Changing Shapes and Editing Points
Text boxes always look like simple rectangles, no matter how you add them.
You can change its shape later to a predefined one or a custom shape by manually editing points.
- Click on the text box and the Shape Format tab will appear on the ribbon.
- Select Shape Format >> Insert Shapes >> Edit Shape >> Change Shape.
- After selecting any shapes from here, the selected text box’s shape will change accordingly.
Change Edit Points:
- To change edit points, you need to click on the edge of the text box. The mouse cursor will have a pointed plus sign with it.
- Now select Shape Format >> Insert Shapes >> Edit Shape >> Edit Points.
- You can click and drag on the edge points to move the edges and change shape manually.
2. Changing Shape Styles
The basic text box we create in Excel has a white background with a grey border. You may need to change that depending on your situation. There are some predefined styles of text boxes in Excel you can choose from.
- To change the shape style, select the text box first to get the Shape Format tab.
- Then select the style you prefer from the Shape Styles group.
- You can access more Quick Styles by clicking on the downward-facing arrow.
- Click on your preferred style.
- The text box will change. We have chosen the Subtle Effect- Black, Dark-1 to get the following style.
3. Changing Fill Color of Text Boxes
If you want to avoid the predefined styles, you can create your custom text box. You can start with the fill color of the text box.
- To change the fill color of text boxes, click on the text box and select Shape Format >> Shape Styles >> Shape Fill.
- Select the color from the drop-down.
There is another Fill option in the Home tab’s Font group too. You can also change it from there after selecting the text box.
4. Removing the Border
The default border of a text box is grey. In case you don’t want the predefined styles, or you want to add a different border to it, you can change it from the Shape Outline.
Click on the text box and select Shape Format >> Shape Styles >> Shape Outline >> No Outline.
The border will be removed after that.
5. Changing Font Size, Style, and Color
Even changing the text box into a predefined style doesn’t change the text inside of it. Some fills don’t match with a black font that is default for a text box.
- You can change the color of the text inside a text box by selecting the box and selecting a color from Home >> Font >> Font Color.
- There are other editing options in the Font group to change styles like Bold, Italic, or Underline.
- You can access different WordArt Styles for the texts in text boxes from the Shape Format tab too.
6. Changing Line Spacing Inside a Text Box
Texts inside a text box can be in paragraphs. Changing line spacings inside it can improve readability. The separation also makes the text box more presentable regardless of the style we choose.
- To change the gap between paragraphs within the text box, you need to select the whole text first.
- Then right-click on the text and select Paragraph from the context menu.
- You can select different line spacing options from the Spacing section of the Paragraph Click OK after the changes.
For example, we are choosing 6pt for spacings after each paragraph. The text will now look like this.
7. Rotating the Text Box
The rectangle in a text box is always horizontally aligned while creating. Rotating the alignment is a rare case. However, you may still want it in scenarios like space constraints, special formatting such as vertical headers, etc.
- To rotate a text box, select a text box and you will see a clockwise rotating icon at the top of the box.
- You can click it and move your mouse cursor to rotate the text box.
See the figure for more details.
8. Resizing the Text Box to Fit Text
We always insert a text box first and then insert text inside of it. The size of the text rarely matches with the text box in this way.
When the text is too large to fit, part of the text gets hidden inside the text box.
Resizing is essential in these cases to make the worksheet visually appealing. The same applies to smaller text in larger text boxes too.
Here are different options to resize the text box and fit it with the text inside of it.
Resizing Text Box Automatically to Fit:
- Select a text box by clicking on the edge of it.
- Press Ctrl+1 to open the Format Shape option.
- Select Text Options >> Textbox
- Under Text Box, check the Resize shape to fit text option.
This will adjust the text box’s height and width to match the text.
Resize to Fit and Wrap:
The previous method doesn’t wrap the text. Instead, it adjusts the width of the text box to fit the text inside.
- You can find the Wrap text in shape under the same options previously mentioned.
- Checking this option will fit the text box’s height, but maintain the width by wrapping the text inside.
This is true, even if you manually change its width later on.
Resize to Fit Using VBA:
- Open up the VBA editor, and insert the following code in the module.
Sub FitTextBoxToText()
Dim ws As Worksheet
Dim textBox As Shape
' Set the worksheet
Set ws = ThisWorkbook.Sheets("8. Resize to Fit Text")
' Replace "YourSheetName" with your actual sheet name
' Set the name of the text box
Dim textBoxName As String
textBoxName = "TextBox 1"
' Replace with the actual name of your text box
' Check if the text box exists
On Error Resume Next
Set textBox = ws.Shapes(textBoxName)
On Error GoTo 0
If Not textBox Is Nothing Then
' Fit the text box to its content
textBox.TextFrame.AutoSize = True
Else
MsgBox "Text box not found!"
End If
End Sub
- Now press F5 to run the code. It will resize the text box.
9. Aligning Text Boxes in Excel
Aligned text boxes are important to ensure a neat and organized layout of a worksheet. However, manually aligning multiple text boxes can always have a human error factor.
Suppose, we have created multiple text boxes containing different sales values in our dataset.
We need to align these text boxes to make them look more presentable. Excel has both horizontal and vertical alignment options for that.
Aligning Text Boxes Horizontally:
- First, select all the text boxes by holding Ctrl on the keyboard and left-clicking on them.
- Then select Shape Format >> Align Objects >> Align Top.
- The boxes will get aligned horizontally after that.
Aligning Text Boxes Vertically:
- Select all the text boxes similarly using Ctrl and left-clicking.
- Now select Shape Format >> Align Objects >> Align Left.
This will align the text boxes vertically.
10. Changing Transparency of a Text Box
A default text box has a white background fill. So, it can hide the cell values beneath it. This can happen for any fill colors also. Changing the transparency will make the cell values visible through the text box.
A text box can cover the cell values it is displaying.
There is always the option to move the text box to see what is beneath it. However, we can also change the transparency of the box. It can give us an idea about the cell values under it depending on the transparency level.
Here is how we can change the transparency of the text box.
- Select the text box by clicking on the edge of it.
- Press Ctrl+1 to open the Format Shape window.
- Select Shape Options >> Fill & Line >> Fill.
- Change the Transparency level under Color.
11. Anchoring Text Box in Excel
A text box is usually attached to a cell. So changing the column width or row height also changes the size of the text boxes in it.
It can be problematic because changing the cell size is very common. We don’t want the size and shape of our text box to change every time that happens.
You can anchor a text box to a cell using the following procedure.
- Select the text box by clicking on the edge of the box.
- Press Ctrl+1 to open the Format Shape window.
- Select Shape Options >> Size & Properties >> Properties.
- Check Don’t move and size with cells.
Lock a Text Box:
With the above procedure, the text box won’t move with column or row size. However, we can still manually select and move the text box.
You can remove that option too by freezing the text box. Here is how we can do this:
- Go to Home >> Cells >> Format >> Protect Sheet.
- Uncheck the Edit objects option only from the Protect Sheet box and click on OK.
Now the text box won’t resize after changing the size of a column or row.
The text box will now freeze to its position. You can still edit cells and perform other Excel actions. You need to unprotect the sheet again to edit the text box again.
How to Copy a Text Box in Excel
If you want to copy a text box, select the text box by clicking on its edge.
Now press Ctrl+C to copy and Ctrl+V to paste.
How to Get Text Box Linked to a Cell in Excel
The point of a text box is to hold highlights and notes in a worksheet. It can also display text values of highlighted cells.
For example, we can show the total sales of our dataset in a text box.
Here is how we can do that.
- First, create a text box using any of the previously mentioned methods.
- Now click on the middle of the box, but instead of writing there, type in the formula bar.
- Type in “=” followed by the cell you want to reference to. For example, we have used =$C$16 to link with C16.
- After clicking on Enter, the value will show on the text box.
- Now double-click on the text box again and type in the extra texts you want to add with it.
Read More: Get a Text Box Linked to Cell
How to Create Dynamic Text Box in Excel
Suppose, we want to select a location from a list and it will give the total sales of the location of our dataset.
Follow the steps below to see how we can do that.
- First, select a cell to insert a location and go to Data >> Data Tools >> Data Validation.
- In the Data Validation box, select the Settings tab.
- Select List for Allow and the range under Source. Our source data is in the B6:B13 range.
- There will be a drop-down arrow available in the cell. Choose a value from it.
- Now insert the following formula in cell C17.
=VLOOKUP(C16,B6:F13,4,TRUE)
- Now insert a text box, select the text box and link it with this cell by typing =$C$17 in the formula bar.
Add extra customization on top of it now if you want to.
Read More: Add a Dynamic Text Box
How to Create Floating Text Box in Excel
Excel also provides the feature to add floating text boxes over worksheets. However, these boxes float over every worksheet once you create them.
You can add a floating text box using the following steps.
- Open the VBA window first.
- Then select Insert >> UserForm.
- From the Toolbox, select TextBox and drag a text box on the userform.
- Set the Multiline option as True and 2 for the ScrollBars option.
- Now create a Module and insert the following code in it.
Sub floating_text_box()
UserForm1.TextBox1.Text = "Monthly sales of accessories in different branches of XYZ company"
UserForm1.Show vbModeless
End Sub
- Press F5 to run the code. The floating text box will now appear on the workbook.
- You can insert any text in the text box just like an ActiveX text box.
Read More: Create Floating Text Box
How to Add Hyperlinks to a Text Box in Excel
Suppose, we want to shift to a new location once we click on a text box with certain text. This can make the workbook or templates containing such text boxes interactive.
We can add such hyperlinks to a text box in Excel in the following way.
- First, insert a text box with any of the methods mentioned.
- Add formatting to the box (optional).
- Right-click on the text box and select Link from the context menu.
- Now select the appropriate place for a link in the Insert Hyperlink For example, we wanted to link to the sheet named “Homepage” from our workbook. So we selected Place in This Document from Link to: section and selected such a named sheet on the right. See the figure for more details.
- Click on OK to finish it.
Now the text box will work as a button. Clicking it will take us to the homepage.
Read More: Anchor Text Box in Excel
How to Apply Conditional Formatting to a Text Box in Excel
We can apply conditional formatting to ActiveX text boxes only. It also includes some VBA usage too.
We will create a text box that changes color with the numeric values inside. The fill color of the text box will be white with positive values and black with negative values.
Follow these steps for more details.
- First, create an ActiveX text box.
- Now select the box and rename it in the Name Box. We have named it “ConditionalTextBox”. (The Design Mode from the Controls group should be turned on for this)
- Right-click on the sheet name and select View Code from the context menu.
- Insert the following code in the editor.
Private Sub ConditionalTextBox_Change()
If ConditionalTextBox.Value < "0" Then ConditionalTextBox.BackColor = rgbBlack
If ConditionalTextBox.Value < "0" Then ConditionalTextBox.ForeColor = rgbWhite
If ConditionalTextBox.Value > "0" Then ConditionalTextBox.BackColor = rgbWhite
If ConditionalTextBox.Value > "0" Then ConditionalTextBox.ForeColor = rgbBlack
End Sub
- Now close the VBA editor.
The color will change to white if the value is positive and black if zero or negative.
How to Convert Text Box Content into Cell Content in Excel
Imagine there is a dataset like this where text boxes are there over the cells. We want to change these texts into cell content.
We can convert text box content into cell content in Excel using the following steps.
- Open the VBA Editor and insert a Module.
- Insert the following code into the module.
Sub ConvertTextBoxToCell()
Dim Sh_xRg As Range
Dim Sh_xRow As Long
Dim Sh_xCol As Long
Dim Sh_xTxtBox As textBox
Set Sh_xRg = Application.InputBox("Select a cell):", "Convert Text Box to Cell ", _
ActiveWindow.RangeSelection.AddressLocal, , , , , 8)
Sh_xRow = Sh_xRg.Row
Sh_xCol = Sh_xRg.Column
For Each Sh_xTxtBox In ActiveSheet.TextBoxes
Cells(Sh_xRow, Sh_xCol).Value = Sh_xTxtBox.Text
Sh_xRow = Sh_xRow + 1
Next
End Sub
- Press F5 to run the code.
- A box will pop up asking for a cell reference. Select cell B6 (the first cell containing the text box).
- Press OK and this will delete the text boxes.
Read More: Convert Text Box to Cell
How to Add Text Box in Excel Graph
We have a graph of our dataset like the following figure.
We can add a text box on it too to highlight notes or add headings on it.
Follow these steps to add a text box to the Excel graph.
- Go to Insert >> Text >> Text Box.
- Click and drag over the chart area where you want to add the text box.
- Now add text in the text box.
Read More: Add Text Box in Excel Graph
How to Delete a Text Box in Excel
In this section, we are going to delete the text box we have created previously.
- To delete the text box, select it by clicking on the edge of the box.
- Now press Delete on your keyboard to delete the text box.
Read More: Delete Text Box in Excel , Remove Text Box Border
What to Do When Text Box is Not Showing in Excel?
A text box, like any other object, in Excel can be toggled off and on for display. The toggle shortcut is Ctrl+6.
Here is a text box that we previously created.
If we press Ctrl+6, it will disappear.
However, it doesn’t mean it is absent from the worksheet. If you find the objects missing in your workbook, use this shortcut.
Download Practice Workbook
That concludes our discussion on what a text box is, how to add and format text box in Excel. We have shown how we can copy a text box, delete it, link it to cells, apply conditional formatting and hyperlinks to it.
We have also covered how to create a dynamic text box that changes its values with a drop-down menu. The tutorial covers how to display a floating text box while working anywhere in a workbook.
We have also discussed a common issue of objects disappearing, including text boxes and how to fix that.
Text Box in Excel: Knowledge Hub
<< Go Back to Learn Excel
Get FREE Advanced Excel Exercises with Solutions!