Colour cell if cell contains a formula (non VBA method)

Grizlore

Active Member
Joined
Aug 22, 2006
Messages
259
Dear All,

I think this can be done by using VBA but i was wondering if there was a way to do this without.

I would like to highlight (with Conditional formatting) if a cell contains a formula. Or if easier, colour a cell if it doesnt contain a formula.

Would anyone know if this is possible and what formula to use in the conditional format formula field to do this please?


Thanks in anticapation

Regards
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I don't think it can be done without use of VBA or at least writing your own custom function as there is no Excel function that does this (as far as I know).

One that I use is:
Code:
Function IsFormula(c As Range) As Boolean
IsFormula = c.HasFormula
End Function
And then apply a conditional format to the output
 
Upvote 0
I can't see how this could be done but if it's just a one off colouring of the cells that you want to do then you could do this by using Edit, Go To, Special, Constants. This will select all the non-formula cells which you can then colour as you wish.
 
Upvote 0
For the record I would go with a VBA approach, either a UDF as Jack has supplied or a routine to colour all constants or formulae as gsbelbin has suggested (in VB this suggestion uses the SpecialCells method).

As far as non VBA solutions go one way will be to use a XLM4 function. These have to be applied in names and then the name is called to get the result (either in a cell formula or conditional formatting).

So let's say you want to test if A1 has a formula. Go to a cell that can be used to flag whether or not A1 has a formula (i.e. use a helper column, so e.g. if column Z is available go to Z1)

Create a new name called 'HasFormula'
Refers to: =GET.CELL(48,!A1)

Now in Z1 type: =HasFormula

This will yield TRUE if it does, else FALSE. Alternatively you can call the name from within Conditional Formatting.
 
Upvote 0
Thanks everyone.

Jon - your non VBA solution works a treat.

All your help is much appreciated !
 
Last edited:
Upvote 0
possibly a silly question, and therefore should be an easy answer

How do I amend this so that it highlights cell WITHOUT a formula?

I have tried changing False to True

= to <>


Feel free to correct me and laugh at my foolishness

:)
 
Upvote 0

Forum statistics

Threads
1,217,364
Messages
6,136,112
Members
449,993
Latest member
Sphere2215

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top