How can I tell if a cell contains a formula versus a number or text? (apart
from looking at it). i want to create a conditional format for cells so that
if users enter a formula (or reference to another cell - basically anything
starting with quot;=quot; , it appears in a different format.
Use a UDF
Function IsFormula(rng As Range)
If rng.Count gt; 1 Then
IsFormula = CVErr(xlErrRef)
Else
IsFormula = rng.HasFormula
End If
End Function--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
quot;R of Steinkequot; gt; wrote in message
...
gt; How can I tell if a cell contains a formula versus a number or text?
(apart
gt; from looking at it). i want to create a conditional format for cells so
that
gt; if users enter a formula (or reference to another cell - basically
anything
gt; starting with quot;=quot; , it appears in a different format.
See
www.mvps.org/dmcritchie/excel...htm#HasFormulaIn article gt;,
R of Steinke gt; wrote:
gt; How can I tell if a cell contains a formula versus a number or text? (apart
gt; from looking at it). i want to create a conditional format for cells so that
gt; if users enter a formula (or reference to another cell - basically anything
gt; starting with quot;=quot; , it appears in a different format.
I tried using the HasFormula in the link and it doesn't work with my
Excel 2003. No referrence to it in quot;Helpquot; and the function doesn't
work. I need the same function. Got any suggestions? edThis user defined function is not built into excel. It's a function that is
created by the user.
If you're new to macros, you may want to read David McRitchie's intro at:
www.mvps.org/dmcritchie/excel/getstarted.htm
Short course:
Open your workbook.
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)
right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side
Paste the code in there.
Function HasFormula(cell)
HasFormula = cell.HasFormula
End Function
(From David McRitchie's site)
Now go back to excel.
Into a test cell and type:
=hasformula(a1)
wrote:
gt;
gt; I tried using the HasFormula in the link and it doesn't work with my
gt; Excel 2003. No referrence to it in quot;Helpquot; and the function doesn't
gt; work. I need the same function. Got any suggestions? ed
--
Dave Peterson
Fantastic!!! Thank you. I used it to conditional format a cell and
works perfectly. Now to learn of the other user defined functions
available in the link you supplied. edAnd one of the neat things about these UDFs is that you can make your own--as
complex as you need.wrote:
gt;
gt; Fantastic!!! Thank you. I used it to conditional format a cell and
gt; works perfectly. Now to learn of the other user defined functions
gt; available in the link you supplied. ed
--
Dave Peterson
- Mar 09 Fri 2007 20:36
how can i tell if a cell contains a formula?
close
全站熱搜
留言列表
發表留言