close

In cell a1 I have a formula. At times whole numbers are entered in this cell
replacing the formula. In a seperate cell is it possible to distinguish if
there is a formula or number in cell a1 using another formula. I do not want
to track changes I just would liek to know what is in cell a1

Thanks
Scott

You can create a userdefined function that returns true or false if the cell
contains a formula:

Option Explicit
Function HasFormula(rng As Range) As Boolean
Set rng = rng.Cells(1)
HasFormula = rng.HasFormula
End Function

Then you can include that test in your formula:

=hasformula(a1)

But if you start entering 5 as =5, then this won't work. It actually looks for
any old formula.

If you're new to macros, you may want to read David McRitchie's intro at:
www.mvps.org/dmcritchie/excel/getstarted.htm

scott wrote:
gt;
gt; In cell a1 I have a formula. At times whole numbers are entered in this cell
gt; replacing the formula. In a seperate cell is it possible to distinguish if
gt; there is a formula or number in cell a1 using another formula. I do not want
gt; to track changes I just would liek to know what is in cell a1
gt;
gt; Thanks
gt; Scott

--

Dave Peterson

Its possible to do this. I can't think of an inbuilt function to do it
however so you'd have to write your own, something like this:

Public Function isFormula(ByRef p_rngTgt as Range) as Boolean

isFormula = p_rngTgt.HasFormula

End Function

If you only need to know however then if you do CTRL ` you toggle
between formulas and values and you can just see.

HTHEnter this UDF into a standard module. Then in some cell where you want the
indicator to be, enter quot;=IsFormula(A1)quot; without the quotes. The result
will be quot;Truequot; if there is a formula in A1 and quot;Falsequot; if not. HTH Otto
Function IsFormula(r As Range) As Boolean

Application.Volatile True

IsFormula = r.HasFormula

End Function

quot;scottquot; gt; wrote in message
...
gt; In cell a1 I have a formula. At times whole numbers are entered in this
gt; cell
gt; replacing the formula. In a seperate cell is it possible to distinguish if
gt; there is a formula or number in cell a1 using another formula. I do not
gt; want
gt; to track changes I just would liek to know what is in cell a1
gt;
gt; Thanks
gt; Scott

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()