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

Written by Allen Wyatt (last updated December 5, 2020)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


1

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()
    Application.Dialogs(xlDialogFormulaFind).Show,2,2
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
'
'
    Sheets("Sheet1").Select
    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.

Note:

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

MORE FROM ALLEN

Printing Documents without Markup

If you have a document with Track Changes turned on, you can accumulate quite a bit of "markup" in it. Here's how you can ...

Discover More

Hyperlinks that Open in a Different Browser Window

When you click a link in a browser, the target of that link might open in the same window or in a new window. Getting an ...

Discover More

Switching between a Dialog Box and the Document

Word uses lots of dialog boxes as a way of setting configuration options and gathering information from users. When ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Limitations On Finding Characters

When you search for information in a worksheet, you expect Excel to return results that make sense. If you don't get a ...

Discover More

Changing the Color Used to Highlight Found Information

When you want to find information in worksheet, Excel can handily locate and highlight that information. If you find the ...

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
Subscribe

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

View most recent newsletter.

Comments

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}] (all 7 characters, in the sequence shown) 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 1 + 1?

2021-04-04 03:34:40

Gian Prakash

When I try to run the second macro i.e. SetFind2() through Auto_Open macro, I get run time error_1004 (Method 'cells' of object '_Global' failed).
However when I run this macro when any excel file is already open then it runs without any error and do the job. I have saved the macro in my personal workbook. Any idea what I'm missing.

Sub Auto_Open()

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

End Sub

I also tried to call sub SetFind2() as separate routine from within Auto_Open macro but got the same error.

Sub Auto_Open()

Call SetFind2

End Sub

Using Sub Workbook_Open() method doesn't give any error but also doesn't make any changes to Look In type : (


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
Subscribe

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.