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.
by Allen Wyatt
(last updated October 20, 2016)
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:
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.
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.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
Creating simple drawing objects is easy in Excel. All you need to do is use the tools made available on the Drawing toolbar.Discover More
Want to change the way that a graphic object appears in your worksheet? You need to edit it, then, using the techniques ...Discover More
When working with charts and chart objects, Excel is very dependent on the mouse. If you don't want to use the mouse, but ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.