Retaining formula after deleting contents.

  • Thread starter Thread starter SiH23
  • Start date Start date
S

SiH23

Hi,

Is is possible to delete the contents of a cell but to retain the formula
assigned to it.

I am trying to duplicate a worksheet and have copied the existing one, but
when I try to delete the contents the formulas are also deleted.

Many thanks for your help in advance.

Simon.
 
Run this short macro on the copied worksheet:

Sub keepformulas()
For Each r In ActiveSheet.UsedRange
If r.HasFormula Then
Else
r.Clear
End If
Next
End Sub
 
Deleting the values in the cells that cause the formula to return a result
other than blank, would result in the formula being in the cell, but
invisible, or zero, or whatever default value the formula concluded.

Vaya con Dios,
Chuck, CABGx3
 

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