formula's in cells

  • Thread starter Thread starter JohnT
  • Start date Start date
J

JohnT

Is there a way of indicating if there is a formula in a
cell? The TYPE function does not seem to pick up
formula's. Is there another function, or some cleverly
written code?? Thanks in advance.
 
From xl2002's help for the worksheet function =Type()

You cannot use TYPE to determine whether a cell contains a formula. TYPE only
determines the type of the resulting, or displayed, value. If value is a cell
reference to a cell that contains a formula, TYPE returns the type of the
formula's resulting value.

You could use a UserDefinedFunction to do the work for you:

Option Explicit
Function CellHasFormula(rng As Range) As Boolean
CellHasFormula = rng(1).hasFormula
End Function

Then you could use it in a cell:

=cellhasformula(a1)

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