VBA Code to identify contents of a cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know a way to identify which cells contain values vs formulas?
 
Hi
msgbox range("A1").hasformula

--
Regards
Frank Kabel
Frankfurt, Germany

SLS said:
Does anyone know a way to identify which cells contain values vs
formulas?
 
Hi SLS,

'\\ Use the SpecialCells method to identify all formula cells in a given
range:
On Error Resume Next
Set rng = Range("A1:D100").SpecialCells(xlFormulas)
On Error GoTo 0

'\\ Check if an individual cell contains a formula:
If Range("A1").HasFormula = True Then
'A1 contains a formula
End If

'\\ Determine if all cells in a range are formulae:
If rng.HasFormula = True Then
'all the cells in rng1 are formulae
End If
 

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

Back
Top