ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determining cellcontents (https://www.excelbanter.com/excel-programming/274489-determining-cellcontents.html)

Stefan J

Determining cellcontents
 
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



Chip Pearson

Determining cellcontents
 
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



"Stefan J" wrote in message
...
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






All times are GMT +1. The time now is 03:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com