Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Sizing Text Boxes and Cells the Same.

Sizing Text Boxes and Cells the Same

by Allen Wyatt
(last updated July 6, 2016)

3

You already know that Excel allows you to create text boxes within your worksheets. You may have a need, at some point, to create a text box that is exactly the same size as a particular cell. If you only have one or two such text boxes to create, the easiest way is to follow these steps:

  1. Display the Insert tab of the ribbon.
  2. Click on the Text Box tool.
  3. Hold down the Alt key as you click and drag to create your text box.

When you hold down the Alt key, it forces Excel to "snap" the sides of your text box to a drawing grid which just happens to match the cell boundaries in your worksheet. The result is a text box that is exactly the desired size.

If you need to create quite a few of these text boxes, all at one time, you can turn the snap-to-gird feature on permanently: Display the Page Layout tab of the ribbon, click the Align tool in the Arrange group, then click Snap To Grid.

If you have many, many such text boxes to create, on lots of different workbooks, you can create the desired text boxes using a macro. The following macro will create a text box directly over the selected cell and size it to be exactly the same size as the selected cell:

Sub TextBox2Cell()
    With ActiveCell
        ActiveSheet.Shapes.AddTextbox _
          msoTextOrientationHorizontal, .Left, _
          .Top, .Width, .Height
    End With
End Sub

With a small change in the macro, you can modify it so that it will create text boxes that are just as large as whatever range of cells you have selected:

Sub TextBox2Selection()
    If TypeName(Selection) = "Range" Then
        With Selection
            ActiveSheet.Shapes.AddTextbox _
              msoTextOrientationHorizontal, .Left, _
              .Top, .Width, .Height
        End With
    End If
End Sub

Regardless of which approach you use to create the text box (manual or macro), it should be noted that if you resize the cell by changing the column width or row height, the size of the text box will also change to match the new cell size.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11359) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Sizing Text Boxes and Cells the Same.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Creating Worksheets with a Macro

Using a macro to add worksheets to your workbook is easy. This tip provides two different methods you can use.

Discover More

Displaying a Count of Zeros on the Status Bar

Excel allows you to display the results of several common worksheet functions on the status bar. The available functions are ...

Discover More

Maximizing Your Editing Space

If you have a large, high-resolution monitor, you may not be starved for screen space. Some people, however, aren't as ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Finding Text in Text Boxes

Want to search for text that may appear in a text box rather than in a regular worksheet cell? You can only perform the ...

Discover More

Placing Textbox Text Into a Worksheet

Want to get rid of your text boxes and move their text into the worksheet? It's going to take a macro-based approach, ...

Discover More

Using Text Boxes

Text boxes are handy for placing information in a container that can "float" over your worksheet. This tip explains what text ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 - 0?

2016-08-03 14:19:39

Eamon

Great tip! How do I select the textbox I just created using VBA?


2016-07-06 12:49:04

PhilP

A really neat way of adding text is as follows:
Add the text box as described above.

Enter the text you want directly into a cell eg.C1

Select the text box and in the function bar type '=' (without the quotes) then click the cell where the text is eg.=$C$1

The text is then displayed in the text box.
The neat thing is that if the cell is updated so is the text box.

You can then right-click the text box to format the text and box.


2014-02-10 21:45:08

L. Howard

How can I add Text to the text box along with a background color.

Say I want the name "Charlie" centered in the text box (no quotes) and fill color as .ColorIndex = 6

Howard


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.