**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: Highlighting Values in a Cell.

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:

- Display the Formulas tab of the ribbon.
- Click Define name in the Defined Names group. Excel displays the New Name dialog box. (See Figure 1.)
- In the Name box, enter the name you want assigned to this formula. For this example, use
**CellHasNoFormula**. - 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. - Enter the following formula in the Refers To box:
- Click OK.

** Figure 1.** The New Name dialog box.

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

=CellHasNoFormulaThe formula returns True or False, depending on whether there is a formula in the cell or nor. If there is no formula, then True is returned and whatever format you specify is applied to the cell. Another approach is to use a user-defined function to return True or False, and then set up the conditional format. You could use a very simple macro, such as the following:

Function IsFormula(Check_Cell As Range) As Boolean Application.Volatile IsFormula = Check_Cell.HasFormula End FunctionYou can then specify the conditional formatting rule type 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. 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 great integrity of the formulas and the worksheet results.

*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, and 2013. You can find a version of this tip for the older menu interface of Excel here: **Highlighting Values in a Cell**.

**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!

When you enter something into a cell, Excel tries to figure out if your entry should be formatted in a particular way. ...

Discover MoreIf you need to easily change the font colors in a group of cells, one of the esoteric commands Excel provides is the ...

Discover MoreExcel often changes the formatting of a cell based on how it parses what you are entering into that cell. This is ...

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

2021-07-04 01:04:31

Roy

@Andy R, and anyone else who wondered, your point 1 about the "48" in Allen's formula:

Yes, as used, the 48 IS a constant. GET.CELL has MANY possible uses and one enters a value such as 48 or the 5 Bigger Don mentions to let the function know which use you wish to make of it. But it is able to take a formula too, one whose result is a numeric value that is one of the values it takes. Additionally, it can take an array of constants so =GET.CELL( {5,48 }, A1) returns both results in a SPILL array. Or one could use GET.CELL( M19, A1) with the value 5 in cell M19. But one cannot use a bare array constant in such a use, that of placing the array constant in cell M19. One must use ={5,48} rather than just the bare {5,48} to use an array constant as the source for M19's value. But... like many older functions, it will just return the first element's value unless you can coerce it back to using the full array for returns. This is because of an interesting fact: even the Excel functions that return a single result (the "first" or the "upper left") actually have the full array calculated and a available. One can force ("coerce") that to be carried forward in a formula IF one wraps it with a function that will do so. Or use a functionality that will do so. And if one's further formula can return a SPILL result, you get all of the returns from the arrays.

So: =GET.CELL(M19#, A1) will take an array in M19 and use all its returns (because we added the "#" (or could have added the rest of a desired range if we'd've preferred, but why when the "#" makes it the dynamic range?) and provide all its results, not just the "first" one. In this case, the use of SPILL functionality forced the return of all of them. Usually one has to find a function that doesn't transform things to much so restoring to the desired output is easy enough, or not actually needed.In other words, GET.CELL must have that parameter, but clearly uses Excel's standard mechanisms for specifying a parameter. (By the way, the ONLY ONLY ONLY thing LAMBDA adds to Excel is giving us access to using Excel's standard mechanisms for specifying a parameter. We have always been able to use Named Ranges to CREATE USER FUNCTIONS, ever since the old macro language and Named Ranges existed, and so has been Turing-complete for at least 30 years. But either we had to limit the entries a user could use for input (frustrating to Excel users), or use the foreign-feeling (to Excel users) method of letting them enter whatever they liked but having to use the mechanism by which they specify the parameter but then an usually put them in any order (still feeling foreign to them), or make the set-up logic so incredibly obnoxious it wasn't worth doing. Not to mention the toughness in using them in new spreadsheets. So I'm not sneering at LAMBDA not being the gift of the gods, but that HUGE thing of accepting standard input mechanisms is really all it adds. Still, it's huge, and so is the fact that the Excel4 macro commands can do it too.

Also for Andy R, there is a formula that directly answers whether a cell contains a formula. I mentioned it below, but explicitly, it ISFORMULA.

As to specifying "current cell", often in a formula one can just leave the reference parameter blank and Excel will proceed as if it has the current cell's address explicitly specified. Add to the formula a volatile expression that does not taint the actual intended result and one can have a "poor man's" way of specifying a formula act upon the current cell that works almost completely automatically. It forces recalc so that Excel does so and updates the value being produced. Without the volatile portion, one would have to press F9 to get that. When I say "poor man's version" I mean vs. using VBA. Using VBA, ANY change desired can be used to trigger the update of value. Using the poor man's version, only cell value changes force updating. Change just a format and one still has to force recalc by using something like F2-Edit and pressing of ENTER. The VBA use would not have to do that. Not a problem in many cases, but consider if one were trying to change a cell color based upon a cell color change elsewhere. (I know that sounds arcane, but cell color enthusiasts buy into cell color massively and seem to hinge everything upon it with a great resistance to combining available techniques... if they will only use a hammer, everything must look like a nail, eh? Even a drinking glass...)

2021-07-04 00:24:10

Roy

This is NOT to disparage the Excel4 Macro commands that can work even today. (Don't misunderstand that either: not only is there the fact that most are meant to PERFORM things as they were macro COMMANDS, not formulas, and so have no real mechanism for working in out-of-the-box Excel, but there is also the fact that one can enable Excel4 macros and macro sheets in regular Excel in which case every one of them I've tried (not that many, but still...) actually does work.) I've used them for their entire existence and GET.CELL was the only way to get a formula out of a formula-bearing cell for most of that time. Several others are handy as well, though a few others that would be have nice Excel functions now so...

Some are actually better. And some must use a mechanism for getting a result that Excel simply no longer has since they produce a big, fat nothing. Cell width is one that still works better. Today's CELL("width",cell) produces an integer while GET.CELL produces a two decimal value.

Interesting point, one that speaks to ONE reason some won't use them, is that, when saving the spreadsheet, Excel tells you it must be saved as a macro spreadsheet (.xlsm). In fact, not only can you just save it as a .xlsx file, but also, that does not strip out the "macros" because you don't actually have any macros to strip out. Open the file and all is still there in the Named Ranges and all still functions nicely. And it doesn't warn you after the first time saving.

Of course, if you enable Excel4 macros and macro sheets, you do have to save as a macro spreadsheet.

But one can substitute FORMULATEXT for GET.CELL now. No extra step taken with care about addressing.

Also, entries like "=27" type entries keep one from using just a bare ISFORMULA. Using FORMULATEXT, one can use =FORMULATEXT(cell)=whatever_your_formula_is (entering the formula text as a string in the formula) which tests that the formula (if there IS one) in the cell matches the formula used by the spreadsheet's writer. (That assumes the user is just "using" and not actively trying to break things.) But then it has to be a bit more complicated to handle the user doing just what he's supposed to be doing, entering simple values, which will cause an error in the formula above.

So, wrap the function with IFERROR:

=IFERROR(FORMULATEXT(cell),"")=whatever_your_formula_is

If a non-formula was entered, the error will be caught by IFFERROR and "" returned (and by definition, "" cannot be what the formula was... unless someone enters ="". (Sigh...) So, more complicated:

=IF(IFERROR(FORMULATEXT(cell),"")="=""""","",IFERROR(FORMULATEXT(cell),""))=whatever_your_formula_is

which covers you unless... your own formula was entirely ="" in which case you need... NO. Like so many things in Excel, and Xeno-like paradoxes, one has to rise above it, climb out of the rabbit-hole and say "ENOUGH"... "Today, my jurisdiction ends here." (Big fan of Silverado.)

Or just use Allen's UDF. It really depends, in my opinion (Honest or otherwise... sheesh, how redundant is "IMHO"? Does it really have to be larded up like that?), it really depends upon whether you control the environment (users must bend to you will and concerns, probably are all in your chain of command, or at least all in your organization), or do you have little to no control? In the former case, the USF rules, unquestionably. In the latter case, doing what you can formula-wise may be your only recourse as UDF's require a macro-enabled workbook be distributed and used and that isn't always possible.

Long live LAMBDA and anything related that comes after it. (You know, in a year or two when we HOI POLOI finally get it.)

2014-10-22 09:47:46

I had never seen Get.Cell before, nor had I seen using "rc" for current cell in an Indirect().

A little research shows Get.Cell is a holdover from Excel4 Macros. There are references on-line that will tell you what other constants give different results. Just search for "Get.Cell".

To get the value of the cell use "5". Warning on that is it returns "0" when the cell is blank, similar to what happens with VLOOKUP().

Oddly, "Get.Cell" cannot be used in a cell formula nor can I find a way to use it in VBA code. The only place I can see an ability to use it is in a Name. It looks like that is why Allen put it into the Name before using it in a Conditional Format formula.

As to using the "rc" in the Indirect(), I did a little experimentation with that.

* "rc" does return the current cell

* Putting a number after "r" or "c" uses the absolute row or column number. So if you wanted to look in Column A of the same row it would read "rc1".

* Putting that number in square brackets, i.e. "[]", gives the relative address. If you wanted to compare the value of the Column A in the current row with Column A of the previous row then the formula would be "=Indirect("rc1",False)=Indirect("r[-1]c1",False)" without the quotes. (I use this type of comparison to set the font color equal to the background color when there is redundant information. It makes spreadsheets much more readable as reports.)

2014-10-20 06:27:00

Barry

2014-10-19 23:49:28

Andy R

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

Can you confirm:

1 - How you know that "48" means a Constant?

2 - I assume since you chose the "not" path, there isn't a variable that tells you the value in the cell is a formula?

This is the first time I've seen "rc" as part of an Indirect. It got me thinking about its use irrespective of the use above.

3 - I assume this essentially means "current cell"?

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.

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

Copyright © 2021 Sharon Parq Associates, Inc.

## Comments