Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. 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 November 6, 2019)


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

You should use caution when using this macro. Make sure you really do want to clear out everything except for cells that contain formulas in the worksheet or workbook before you run this macro. It would be a shame to accidentally get rid of the contents of cells that you really needed to keep. It would be a good idea to add a msgbox that contains a warning and gives you the chance to cancel the operation.


If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9097) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. 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. ...


Deleting an AutoText Building Block

At some point you may want to delete an AutoText entry you previously created. Here's the steps to follow.

Discover More

Automatic Row Height for Wrapped Text

When you format a cell so that the information within it can wrap to multiple lines, you may be surprised if Excel ...

Discover More

Separating Text by Color

Excel allows you to use multiple colors to format the text in a cell. If you want to later separate that text to ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Conditionally Deleting Rows

Want to delete a bunch of rows in a worksheet based on the value in a certain cell of each row? There are a couple of ...

Discover More

Automatically Breaking Text

Want to convert the text in a cell so that it wraps after every word? You could edit the cell and press Alt+Enter after ...

Discover More

Using the Fill Handle from the Keyboard

The fill handle can save a huge amount of time when you are editing a worksheet. If you are really good at using 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. Maximum image size is 6Mpixels. 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 4 - 0?

2018-01-04 06:56:04


Is There any way to keeping the formulas same as its entered and changing the value as of our need?? Please help.!!

2017-10-04 10:20:18


Please any one tell me to clear /reset the contents in cell, but don't disturb the Macros and formulas

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.