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:
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.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
The find and replace used in Excel is less powerful than its counterpart in Word, so it is not able to do some of the ...
Discover MoreWhen doing searches in Excel, you can use wildcard characters in the specification of what you are searching. However, ...
Discover MoreWhen you search for information in a worksheet, you expect Excel to return results that make sense. If you don't get a ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2021 Sharon Parq Associates, Inc.
Comments