Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and 2021. 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: Highlighting Values in a Cell.

Highlighting Values in a Cell

Written by Allen Wyatt (last updated December 4, 2021)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and 2021


2

Trev has a table of sales forecasts by product that several users review and update. The forecasts are initially set with various formulas, but the users are allowed to override the formulas by entering a value into any cell that contains one of the formulas. If a user does this, it would be helpful for Trev to have Excel somehow highlight that cell.

There are a couple of approaches you can take. First, you could use conditional formatting to do the highlighting. Set the conditional formatting rule type to Format Only Cells that Contain, "Cell Value" "Not Equal To," and then enter the formula as the comparison. This will tell you when the value in the cell does not equal whatever the formula is, but a potential "gottcha" is if the person overrides the formula with the result of that formula. For instance, if the formula would have produced a result of "27" and the user types "27" into the cell.

Another possibility is to define a formula in a named constant and then use that named constant in a conditional format. Follow these steps:

  1. Display the Formulas tab of the ribbon.
  2. Click Define name in the Defined Names group. Excel displays the New Name dialog box. (See Figure 1.)
  3. Figure 1. The New Name dialog box.

  4. In the Name box, enter the name you want assigned to this formula. For this example, use CellHasNoFormula.
  5. Select whatever is in the Refers To box, at the bottom of the dialog box, and press Del. This gets rid of whatever Excel had there before.
  6. Enter the following formula in the Refers To box:
  7.      =NOT(ISFORMULA(INDIRECT("rc",FALSE)))
    
  8. Click OK.

Note that the ISFORMULA function (step 5) was introduced in Excel 2013. If you are using Excel 2007 or Excel 2010, then you should use the following formula in step 5, instead:

     =NOT(GET.CELL(48,INDIRECT("rc",FALSE)))

With the formula set up, you can define some conditional formats and use this named formula in the format. Simply set the conditional formatting rule type to Use a Formula to Determine which Cells to Format and enter the following formula in the condition:

=CellHasNoFormula

The formula returns True or False, depending on whether there is a formula in the cell or not. If there is no formula, then True is returned and whatever format you specify is applied to the cell.

Another approach is to forgo the named constant approach and, instead, use a formula directly in your conditional formatting rule. Make sure you define the rul as Use a Formula to Determine which Cells to Format and enter the following formula in the condition if, for instance, you are conditionally formatting cell C1:

=NOT(ISFORMULA(C1))

The formula returns True if there is no formula in the cell, so the conditional format is applied.

If you are using Excel 2007 or Excel 2010, you can put together your own ISFORMULA function using a macro, like this:

Function IsFormula(Check_Cell As Range) As Boolean
    Application.Volatile
    IsFormula = Check_Cell.HasFormula
End Function

You can then use your own IsFormula in the conditional formatting rule, as already discussed.

The only downside of using any of these formulas to determine if a formula is in the cell is that it cannot determine if the formula in the cell has been replaced with a different formula. This applies to both the macro approach and the defined formula approach.

A totally different approach is to rethink your worksheet a bit. You can separate cells for user input from those that use the formulas. The formula could use an IF function to see if the user entered something in the user input cell. If not, your formula would be used to determine a value; if so, then the user's input is used in preference to your formula. This approach allows you to keep the formulas you need, without them being overwritten by the user. This results in greater integrity of the formulas and the worksheet results.

def

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 (9270) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and 2021. You can find a version of this tip for the older menu interface of Excel here: Highlighting Values in a Cell.

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

Avoid Using the Normal Style

The basis of almost all styles in Word is the Normal style. Here's a good reason why you shouldn't use it.

Discover More

Adding a Little Animation to Your Life

Tired of the same old boring Excel look? You can add some life to your worksheets by introducing some animation. Here's ...

Discover More

Adding Paragraph Numbering

You may search high and low for a way to add automatic numbers to paragraphs in a document. You won't find the ...

Discover More

Best-Selling VBA Tutorial for Beginners Take your Excel knowledge to the next level. With a little background in VBA programming, you can go well beyond basic spreadsheets and functions. Use macros to reduce errors, save time, and integrate with other Microsoft applications. Fully updated for the latest version of Office 365. Check out Microsoft 365 Excel VBA Programming For Dummies today!

More ExcelTips (ribbon)

Using Strikethrough Formatting

Need a line through the middle of your text? Use strikethrough formatting, which is easy to apply using the Format Cells ...

Discover More

Adjusting Cell Margins for More White Space

Is the information in your cells too jammed up? Here are some ways you can add some white space around that information ...

Discover More

Determining Font Formatting

If you need to determine the font applied to a particular cell, you’ll need to use a macro. This tip presents several ...

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 0 + 1?

2021-12-06 10:36:15

RKeev

Just make it easy with Ctrl ~ to see formulas/constants
Or Highlight if cell does not contain an equal sign


2021-12-04 10:22:31

Roy

For the idea of changed formula detection, adding a clause to the formula that gets the formula text and compares it to a string that you create from the "correct" formula text would solve that.

So FORMULATEXT, or either GET.CELL (parameter 48, as used here, or... 6, I think, or near that) using our fine friend GET.CELL.

By the way, not precisely related, but either GET.CELL will return the cell contents, formula they may be, or not. FORMULATEXT will return an error if anything other than a formula is present. That difference can be of use. Not necessarily better use than, say, ISFORMULA, but of use.


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.