Check cell formula

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

Guest

I wanted to clear all the cells which have formula on it.
Are there any function to check this like "Isformula" in VBA?

Any information is great appreciated,
 
Try something like this...

Sheet1.Cells.SpecialCells(xlCellTypeFormulas).ClearContents

which clears all of the formulas on sheet 1
 
Thanks for the informaiton,
It works, but it fails if there is no formula on the spreadsheet.
Should I check that does spreadsheet have formula before run the code?

Thanks again,
 
Hi Souris,

Whenever using the specialCells method it is advisable to use a
precautionary error handler.



Dim SH As Worksheet
Dim rng As Range

Set SH = Sheets("Sheet1")

On Error Resume Next
Set rng = SH.Cells.SpecialCells(xlFormulas)
On Error GoTo 0

If Not rng Is Nothing Then rng.ClearContents
 
Is it possible to clear all the format like color and font...etc

Thanks millions,
 
Hi Souris,
Is it possible to clear all the format like color and font...etc

Dim SH As Worksheet
Dim rng As Range

Set SH = Sheets("Sheet1")

On Error Resume Next
Set rng = SH.Cells.SpecialCells(xlFormulas)
On Error GoTo 0

If Not rng Is Nothing Then rng.Clear
 

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