Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Clearing Everything Except Formulas.

Clearing Everything Except Formulas

by Allen Wyatt
(last updated January 17, 2015)


Roni wants want to clear everything in a worksheet 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:

  1. Press F5. Excel displays the Go To dialog box. (See Figure 1.)
  2. Figure 1. The Go To dialog box.

  3. Click the Special button. Excel displays the Go To Special dialog box. (See Figure 2.)
  4. Figure 2. The Go To Special dialog box.

  5. Select the Constants radio button. The four check boxes under the Formulas option then become available. (This can be a bit confusing. Why Microsoft made the Constants radio button control some check boxes under a different radio button is not immediately clear.)
  6. Make sure that all the check boxes under the Formulas radio button are selected. (They should be selected by default.)
  7. Click OK. Excel selects all the constants (cells that don't contain formulas) in the worksheet.
  8. Press the Del key.

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
    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.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9097) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Clearing Everything Except Formulas.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Viewing Workbook Statistics

Excel keeps track of a range of stats about each workbook you use. If you want to take a look at those stats, it's easy; just ...

Discover More

Defining Protected Sections as a Building Block

Building Blocks can be very useful in creating documents from standard parts and pieces. But what if the text you want to use ...

Discover More

Making AutoCorrect Automatically Recognize the Replace Word

When you select some text in your document and then display the AutoCorrect dialog box, it can seem a bit odd that sometimes ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (ribbon)

Deleting Everything Up to a Character Sequence

Sometimes you have too much information in a cell and you need to "pare down" what is there to get to the info you really ...

Discover More

Shortcut for Selecting a Data Range

Want to select all the data in a contiguous section of a worksheet? The shortcut discussed in this tip makes it very easy.

Discover More

Checking for a Value in a Cell

Need to figure out if a cell contains a number so that your formula makes sense? (Perhaps it would return an error if the ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is three minus 2?

2017-07-19 15:53:15


I'm not able to make this work on anything but plan numbers. Is there another way to do this for date formulas? I built a production scheduling tool and would like to remove all the dates but leave the formulas so people can start with a clean slate instead of placeholder dates.

2017-06-17 15:24:30



.ClearContents does not alter formats or validation


Why not name the data area 'Input' and then just delete the old values

2017-06-16 01:38:00


How to clear without clearing a formats and data validation?

2017-04-24 09:04:47

Mitchell Billion

Can you clear everything but the first row that are headers and keep all formulas

2017-02-22 20:56:31


You probably know this already, but Step 2 of your instructions shows "Comments" selected, not "Constants".

2017-02-03 10:31:55

Valerie Fieldwebster

Great help. Thanks

2016-12-03 08:23:32

lakhan singh

How to possible that

sum formula worked but not delete formula or no edditing/correction in formula

2016-09-21 05:36:57

Dennis U

I would also appreciate advice if there is a possibility to delete only unprotected cells. Thanks a lot! Would make my life a lot easier.

2016-09-01 05:04:06


I used this method (F5 GoTO, Select "Constants", Unselect "text, the DEL) - but the application freezes and reboots, taking its time to do so. I am using Excel 2016.

Any advice?

2016-02-16 09:08:01

Paolo Gera

Good afternoon;
Is there any means to remove values in ALL UNLOCKED cells within a protected worksheet? If you remove all but formulas you'll get rid of all cells contents that might contain names and/or other complementary information which you do not want to eliminate.
Thanks in advance...

2016-02-16 08:16:42

Paolo Gera

Is there any means to remove values in ALL UNPROTECTED cells only? If you remove all but formulas you'll get rid of all cells that might contain names and/or other complementary information which you do not want to eliminate.
Thanks in advance...

2016-01-20 05:13:09



The above macro should work fine. Have you allowed macro execution in Excel options? Are you using .xlsm or .xls files instead of .xlsx ?

2016-01-19 08:44:07


I have the same problem as Malika.

Can anyone advise.

2016-01-15 14:00:45



2015-12-29 14:29:22

Malika Daniels

Good Afternoon,

Is there a way to remove the values of an Excel spreadsheet but keep the formulas? I have a 12 page Excel spreadsheet that I need to clear for the year 2016 but when I follow the instructions I found online, it erases the values and all the formulas I have saved. HELP!!
Thank you!

2015-01-23 09:26:59

Glenn Case

To address Wiily's cautionary final note in his 20 Jan post, when I do something like this, I typically add a msgbox with a warning and the ability to cancel the operation. That has saved me a few times...

2015-01-22 05:21:56



Hmmm, seems you are right. I exclusively use On Error GoTo so I thought the On Error Resume behaved the same way.

2015-01-21 10:48:37

Willy Vanhaelen


Nope, you're wrong. After an 'On Error Resume Next', all runtime errors will be ignored until the procedure ends or an 'On Error GoTo 0' is met. A call to another procedure will suspend it during that call.

2015-01-21 05:19:55



On Error should be inside the loop. Say you have multiple sheets with no constants on them; the error will be triggered multiple times.

However once an On Error has been triggered (or the Resume instruction executed, in case you are using an On Error GoTo), you need to reload it to work; which means the second sheets without constants will give you an execution error.

2015-01-20 11:25:13

Willy Vanhaelen

There is no need to set 'On Error Resume Next' on and off for each worksheet. Just place it before the For Next statement and leave out 'On Error GoTo 0'.

Also 'Set wks = nothing' is unnecessary because it's the last statement of the macro and when it finishes the memory used by wks is freed anyway.

The 23 can also be left out because it's the default. The macro can thus be rewritten like this:

Sub ClearAllButFormulas()
Dim wks As Worksheet
On Error Resume Next 'ignore errors in case there is only formulas
For Each wks In Worksheets
End Sub

One final note: this is a very dangerous macro because when you run it accidentally in any workbook, everything except formulas in the entire workbook is gone. So, unless you know exactly what you are doing, the manual procedure described in this tip is preferred. You can always undo it when you are not satisfied with the result which is not the case when a macro does it.

2015-01-19 09:08:59


Couple questions about the macro:

1) What does the On Error GoTo 0 do? All errors will be caught by Resume Next, I don't see when this one would be triggered.

2) What is the 23 for? By checking the function on VBA I see that it's an optional argument called Value, but I don't see what it does.

2015-01-17 22:53:36


This tip shows how Excel saves time for the familiars.

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.