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

Sizing Text Boxes and Cells the Same

Written by Allen Wyatt (last updated September 5, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


1

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 Drawing toolbar.
  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. Just choose Draw (on the Drawing toolbar) | 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.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2192) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) 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

Positioning a Graphic in a Macro

Macros are a great way to process information in a worksheet. Part of that processing may involve moving graphics around ...

Discover More

Default Worksheet when Opening

When opening a workbook, you may want to make sure that a particular worksheet is always displayed first. The only way to ...

Discover More

Converting List Types

There are two types of common lists you can create in Word: bulleted lists and numbered lists. You can switch between the ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Changing the Size of a Graphic

Adding a graphic to a worksheet is easy. Getting that graphic to just the right size may take a little bit of trial and ...

Discover More

Specifying an Order for Drawing Objects

Drawing objects can be layered over each other in almost any manner you desire. If you want to change the order in which ...

Discover More

Adding AutoShapes

The graphics features of Excel allow you to add a number of predefined AutoShapes to a workbook. If you want to add ...

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}] (all 7 characters, in the sequence shown) 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 6 - 0?

2023-01-20 13:24:37

EXCEL_NOVICE

How would you make these work with an ActiveX Text Box? I tried replacing ActiveSheet.Shapes.AddTextbox _ with ActiveSheet.Forms.AddTextbox _ and it did not work.


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.