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: Changing Default Search Settings.

Changing Default Search Settings

by Allen Wyatt
(last updated December 3, 2019)


When Dan displays the Find dialog box, the default settings are to search within worksheet and to look in formulas. He would like the default to be within workbook and to look in values, so he is wondering if there is a way to change the default.

Excel doesn't allow you to specify what settings you want for a default in the Find dialog box. There is a bit of a way around this seeming limitation, however—at least a partial way. Excel remembers the last settings in the Find dialog box for the entire Excel session. (The settings are not reset until you exit and restart Excel.) This means that all you need to do is create a small macro that will set the settings you want in the dialog box.

There are two ways you can do this. The first is to create a macro that sets the options in the dialog box directly, such as this:

Sub SetFind1()
End Sub

The second way is to utilize the Find method of the Cells object, in this manner:

Sub SetFind2()
    Dim c As Range
    Set c = Cells.Find(What:="", LookIn:=xlValues, LookAt:=xlPart)
End Sub

Either of these will work just fine, to a point. (More about that in a moment.) All you need to do is run the macro when you first start Excel, either manually or as part of an Auto_Open macro. The settings in the dialog box are then changed for the remainder of the Excel session, unless you manually change them.

Now, to the point. It seems that there is no way to change the Within setting of the dialog box. This setting defaults to looking in the Worksheet. You can manually change it to Workbook, and Excel will dutifully remember the setting for your current session. However, you cannot seem to change the setting within VBA. You'll note that neither of the sample macros, above, change this particular setting. Further, if you record a macro in which you change the two settings (Within and Look In), you end up with something that looks like this:

Sub Macro1()
' Macro1 Macro
    Cells.Find(What:="", After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlPart, SearchOrder:=xlByRows, _
        SearchDirection:=xlNext, MatchCase:=False).Activate
End Sub

If you save the workbook in which this macro exists, restart Excel, and then examine the settings in the Find dialog box (press Ctrl+F), you'll note that the settings are back to the default of searching within the worksheet and looking in formulas. Run the macro and then look at the dialog box again; you should see that the settings are for looking in values within the worksheet; the macro doesn't set the Within setting, even though you recorded it when you set Within to Workbook.


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 (8802) 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: Changing Default Search Settings.

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


Changing Default Tab Stops

If you don't explicitly set tab stops in a paragraph, Word relies upon a default tab stop distance. You can adjust that ...

Discover More

Adding Buttons to Your Worksheet

You can easily add a button to your worksheet that will allow you to run various macros. This tip shows how easy it is.

Discover More

Making Modal Dialog Boxes Appear in Front of Workbooks

Perhaps the most common way of communicating with programs is through the use of dialog boxes. We expect dialog boxes to ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Finding and Replacing in Text Boxes

Finding and replacing information in a worksheet is easy. Finding and replacing in other objects (such as text boxes or ...

Discover More

Find and Replace in Headers

Using Find and Replace is something quite routine in Excel, as it easily allows you to find and replace information in ...

Discover More

Searching for Line Breaks

If you need to find where line breaks are located in cells, there are a couple of ways you can proceed. Here's a quick ...

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 two minus 0?

2020-08-13 09:48:59


This is so seriously retarded?

What moron at Microsoft decided that people want to search in a FORMULA?

2020-03-05 17:06:35


I'm in the newest version of Excel for Mac. Can someone give me the macros to set my default searches to the entire workbook and formulas? Currently the defaults in this new version are sheet and values. Values excludes hidden cells and that really sucks for me. Thanks in advance!

2018-12-11 16:23:04


Two problems with SetFind2 - first, it causes the following error: "Run-time error '91' Object variable or With block variable not set." I believe you need a "Set" before the "c". This has already been mentioned, but the page still has not been corrected.

Second, if your macro displays a userform, and the code within the form does a Range.Find, and you then Hide the form (returning back to the spreadsheet, but with the form still alive), a find will not work because it will only search within the selected range, which is nothing, because the Range.Find what:="" fails. So how does one reset the search range as well as the default parameters?

2017-09-09 08:52:34

Willy Vanhaelen

See my comment of 2015-06-24

2017-09-08 15:25:18


Thank you very much for this. I get an error on Excel startup

Method 'Cells' of Object'_Global' failed

From my googling it seems I have to define Cells or the worksheet somehow, but I'm not skilled enough to know what to do. I don't know if this is an Office16 change.

Any help gratefully received.

2017-01-24 13:29:41


This worked, but not when I hid the PERSONAL.XLSB

I tried adding a "SendKeys" ESC in case it was the hidden dialog box that was the problem but that didn't help.

Have you made this Auto_Open in a hidden Personal.XLSB? If so - what exactly do I put in AutoOPen()?

Many thanks indeed

2016-07-11 10:43:03

Just Me

Perfect! Thank you!

Sub SetFind1()
End Sub

2015-06-24 11:46:19

Willy Vanhaelen


The second macro in this tip is not OK. This one will do the job:

Sub SetFind2()
Dim c As Range
Set c = Cells.Find(What:="", LookIn:=xlValues, LookAt:=xlPart)
End Sub

2015-06-23 16:34:02


Thanks for this. The first option works great, but when I tried it using the second option, I get an error that the "Object variable or With block variable not set." Any suggestions?

Sub SetFind2()
Dim c As Range
c = Cells.Find(What:="", LookIn:=xlValues, LookAt:=xlPart)
End Sub

2014-12-30 16:43:10

Martin Mirsky

This limitation of Excel has been an annoyance for years. SendKeys following the ActiveSheet command works on the macro sheet not the worksheet.

My way around this is using an old program called Keyboard Express, which is similar to the Sendkey command. The key series is assign to the shift-control-f for convenience.
Series used was:

2014-12-11 01:44:37


I've tried this code with excel 2013 but my excel become crash and not responding

2014-11-14 10:16:01

Willy Vanhaelen

Hold down Shift and click Find Next

2014-11-12 07:29:32


Question: "Ctrl+F" - can we expect excel to start search from the end of the sheet ?

2014-08-20 08:22:17



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.