Searching a Workbook by Default, Take Two

Written by Allen Wyatt (last updated December 31, 2019)
This tip applies to Excel 97, 2000, 2002, and 2003


A few issues ago a tip appeared about how to display the Find and Replace box and set the Within drop-down list to Sheet. At the time, I reported that I had not come across a way to actually accomplish this, as VBA didn't provide a way to display the same Find and Replace dialog box that appears when you press Ctrl+F.

This past week I found out the way to do this, thanks to the contribution of a generous ExcelTips subscriber. The following macro shows how to accomplish the task:

Sub DoBox()
    ActiveSheet.Cells.Find What:="", LookAt:=xlWhole
    Application.CommandBars("Worksheet Menu Bar").FindControl( _
      ID:=1849, recursive:=True).Execute
End Sub

The Find method allows you to set the different parameters in the Find and Replace dialog box, and then the CommandBars object is accessed to actually display the dialog box.

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 (2486) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Getting Rid of Spaces in Merged Data

When you merge information with a Word document, you may not be completely satisfied with the appearance of some of the ...

Discover More

Sticking with the Dashes

By default, dashes don't "stick" to the text that follows them. Here's one way around this normal formatting convention.

Discover More

Should I Leave My Computer On All the Time?

Do you turn your computer on and off all the time? Do you really know if this is good for your computer or not?

Discover More

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!

More ExcelTips (menu)

Using Check Boxes

Check boxes, just like those used in Windows dialog boxes, can be a great addition to a worksheet. Here's how to add them ...

Discover More

Watching Cell Values

Want to know what is happening in certain cells in your worksheet? Using the Watch Window is a great way to keep an eye ...

Discover More

Deleting a View

When you no longer need a view, you can get rid of it by deleting it. Deleting unnecessary views is a good idea because ...

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 one less than 9?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon 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.