Showing Text when a Cell is Empty

Written by Allen Wyatt (last updated July 22, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


2

Sheryl can use Conditional Formatting to make a cell appear a certain color if the cell is empty. Instead of a different color for the empty cell, she would like the empty cell to show some text. For instance, if the cell is empty, she might want to have it show "Customer Name," which would serve as a prompt to the user. Sheryl wonders if there is a way to do this sort of "conditional formatting" that shows text.

The short answer is no, this cannot be done. The traditional way to get around it is to separate your prompts from your input cells. For instance, if the user input is expected in cell B4, you might put the wording "Customer Name:" (with the colon) in cell A4. If you want the wording to disappear when the customer name is entered, you could, instead, use a formula in cell A4:

=IF(ISBLANK(B4),"Customer Name","")

There's also an approach you can use that takes advantage of the way that Excel deals with "cell overrun" when the cells contain text. Let's say, for example, that (again) your user input is expected in cell B4. You could make column A very narrow—say, about a single character wide—and then in cell A4 press the Space Bar a few times and type "Customer Name." As long as there is nothing in cell B4, what you typed in cell A4 is displayed, but it looks like it is in cell B4. When someone types something in cell B4, this blocks what is in cell A4 from being displayed. You could even, if desired, make the text in cell A4 a light gray, so it appears subdued when displayed.

If you prefer to go a macro route, you'll want to create one that is triggered whenever there is a change in the worksheet. This would go into the code module for the worksheet being used:

Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$B$4" Then
        If Target = "" Then
            ' Cell is empty; mark it and make gray
            Target = "(Customer Name)"
            With Selection.Font
                .ThemeColor = xlThemeColorDark1
                .TintAndShade = -0.249977111117893
            End With
        Else
            ' Cell contains something; remove gray
            With Selection.Font
                .ColorIndex = xlAutomatic
                .TintAndShade = 0
            End With
        End If
    End If
End Sub

Note that the macro only kicks into action if the cell being changed is cell B4.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (614) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

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

Macro Runs Slowly, but Steps Quickly

When you have a macro that processes a huge amount of data, it can seem like it takes forever to finish up. These ...

Discover More

Controlling Chart Gridlines

Gridlines are often added to charts to help improve the readability of the chart itself. Here's how you can control ...

Discover More

Use Filenames that Sort Properly

If you take some care when you name your document files, you'll find it much easier to manage those files at a later ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Combining Multiple Rows in a Column

Do you need to concatenate the contents of a range of cells in the same column? Here's a formula and a handy macro to ...

Discover More

Highlighting the Rows of Selected Cells

If you lose your place on the screen quite often, you might find it helpful to have not just a single cell highlighted, ...

Discover More

Deleting Rows Containing Struck-Through Text

Excel makes it easy to delete rows in a worksheet, but it can be more difficult to figure how to delete rows if you only ...

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 8 - 5?

2023-08-01 10:16:43

J. Woolley

To select all empty cells between A1 and Ctrl+End:
1. Press F5
2. Click Special...
3. Pick Blanks
4. Click OK


2023-07-31 14:26:57

David Gray

Another option that I employ regularly is to define a conditional format that is applied to a cell when the length of its value is zero. For example, the conditional format for cell A1 is "=len(a1)=0".

I'll define my format, and set the fill to a pattern or a distinctive color, then apply it everywhere else that it matters by copying the format from the original cell, then using Paste Special to apply it to relevant cells. Since the cell reference is unanchored, it will adjust to the location of each destination cell.


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.