Delete content but not formulas

  • Thread starter Thread starter Jake F
  • Start date Start date
J

Jake F

I was asked if there is a way to remove the content of spreadsheets but to
keep the formulas. I'm not sure why the person wants to do this, but want to
give them a correct answer. Thanks.
 
To remove values only from Excel:
Select all cells on the worksheet, or just one cell.
Press F5 (or Ctrl + G or Edit -> Goto)
Click the "Special" button.
Click "Constants"
Numbers, Text, Logicals, Errors should be checked.
Click OK.
Press Del (or Edit -> Clear -> Contents)
Repeat for other worksheets as needed.

Or use a macro -- for just the active sheet:
Sub RemoveValuesOnly()
Dim cell As Range
For Each cell In ActiveSheet.UsedRange.Cells
If Not cell.HasFormula Then
cell.ClearContents
End If
Next
End Sub

Or for every worksheet in the active workbook:
Sub RemoveValuesOnly()
Dim cell As Range, wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
For Each cell In wks.UsedRange.Cells
If Not cell.HasFormula Then
cell.ClearContents
End If
Next
Next
End Sub
 

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