
Tips.Net > ExcelTips Home > Editing > Clearing > Clearing Everything Except Formulas
Summary: Worksheets can contain an amazing variety of both formulas and values. If you want to get rid of the values in a worksheet but leave the formulas unchanged, how you accomplish the task may seem elusive. Apply the techniques in this tip, and the task can be done quickly and easily. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)
Roni wants want to clear everything in a workbook except for cells which may contain formulas. This task can be completed either manually or through the use of a macro.
If you want to do the clearing manually, you can follow these steps:
This works great if you only need to clear out the non-formula contents of a worksheet once in a while. If you need to do it more often, then you can simply use the macro recorder to record the above steps. Or, if you prefer, you can create your own macro from scratch, such as the following one:
Sub ClearAllButFormulas()
Dim wks As Worksheet
For Each wks In Worksheets
'ignore errors in case there is only formulas
On Error Resume Next
wks.Cells.SpecialCells _
(xlCellTypeConstants, 23).ClearContents
On Error GoTo 0
Next
Set wks = Nothing
End Sub
This macro is particularly useful if you need to clear out all the non-formula cells in an entire workbook. The reason is because it does the clearing on every worksheet in the entire workbook, without you needing to do the clearing manually.
Tip #3226 applies to Microsoft Excel versions: 97 2000 2002 2003 2007
PivotTables Got You Perplexed? PivotTables for the Faint of Heart shows how you can start using Excel's PivotTable tool right away to spin your data into gold! You discover how easy it really is to crunch the numbers you need to crunch. Uncover the power of creating PivotTables, editing them, formatting them, customizing them, and much more.
Check out PivotTables for the Faint of Heart today!
Thousands of ExcelTips, available for immediate download. Have all the Microsoft Excel info you need, right at your fingertips. (more information...)
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site