Distinguishing cell formula from value.

  • Thread starter Thread starter buczacz
  • Start date Start date
B

buczacz

How can I use VBA code to examine the content of a cell so as to
determine whether it contains a hard value, such as the number 12,
rather than a formula that yields the value 12?

It suspect that there should be a way to search the cell content for an
equal sign (=) in the alphanumeric character string using *=* where *
substitutes for any group of characters.

Alternatively, perhaps there is something line the fuction

cell("type", A1)

where it returns a character string depending on whether the cell in
location A1 is blank, contains a label, or returns a value. The
cell("type") function does not distinguish between a hard value and a
formula that yields a value.

Suggestions??

Thanks Michael
 
Hi Michael,

You could use something like:

If Sheet1.Range("A1").HasFormula Then
''' Your code here.
End If

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
Works great... Thanks ... !!!!!

Researching the .HasFormula function also lead me to the web pages of
David McRitchie that have a wealth of additional information.
 
Back
Top