Determining cellcontents

  • Thread starter Thread starter Stefan J
  • Start date Start date
S

Stefan J

How do I, programmatically, determine whether a specific
cell contains a formula or a number?

I have written something like this

....
CellContents = ActiveCell.Formula
MsgBox CellContents
....

This shows the cellcontents in the messagebox, but I
cannot find out how to have the macro to determine whether
or not this is a formula. In this case, I want to delete
the whole row if the cell content is a formula.

Hope someone could help me with this problem.

Stefan J
 
Stefan,

Use the HasFormula property. This will return True if the cell
contains a formula, or False if the cell does not contain a
formula. E.g.,

If ActiveCell.HasFormula Then
MsgBox "Formula"
Else
MsgBox "Not A Formula"
End If

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
Back
Top