Formula OR value in cell?
Formula OR value in cell?
(OP)
Can anyone tell me how to test whether a cell contains a directly input value or a formula so that I can use the test in a conditional format?
e.g. if a cell SHOWS 7, test is it a directly entered 7, or is it the result of a formula say =4+3?
e.g. if a cell SHOWS 7, test is it a directly entered 7, or is it the result of a formula say =4+3?
RE: Formula OR value in cell?
MsgBox Range("A1").Formula
For example
Entered formula 7 / =3+4
.Value 7 / 7
.Formula 7 / =3+4
Now you can check whether there's a formula or a value in the cell.
Success!
cactus13
RE: Formula OR value in cell?
Public function ISFORMULA(rng as range) as boolean
ISFORMULA=rng.hasFormula
end function
declaring a function as public will make accessible from the worksheet.
Try it!
RE: Formula OR value in cell?
Define a range
Name: IsFormula
Refers to: =LEFT(GET.CELL(6,INDIRECT("rc",FALSE)),1)="="
Then get out of this dialog box.
Next, select the all of the sells that you would like to conditionally format (that is, select all of the cells that you would like to test for a formula).
Go to the conditional format dialog box and type this condition:
Formula Is: =IsFormula
RE: Formula OR value in cell?
Thanks - your solution works fine & I will use it.
However I don't understand how it works, because there is no reference in Excel help index (Excel 97)to the "GET.CELL" function nor to the particular variant of the "INDIRECT" function you use.
RE: Formula OR value in cell?
Thanks - your solution works fine too. I shied away from using it at first (scared of the VBA word!), but I can see now that by having it as a Public Function in my Personal.xls , that I can use it on any spreadsheet without having to enter lengthy formulae in the conditional formatting.