Determining whether selected cell has value or formula?

J

John Wirt

I have a simple question. in VBA, how can one determine whether the
currently selected cell has a value or a formla in it?

John Wirt
 
C

Chip Pearson

John,

Use the HasFormula property. E.g.,

If Range("A1").HasFormula = True Then
' cell has formula
Else
' cell doesn't have formula
End If


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

John Wirt

If I include this before the statement where I want to obtain the formula in
a cell, I will be able to only select when the cell contains a formula. The
program will be better.

John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top