KutoolsforOffice — One Suite. Five Tools. Get More Done.

How to always search the entire workbook in Excel?

AuthorXiaoyangLast modified

Excel's Find and Replace dialog lets you search either the current worksheet or the entire workbook. If the Within setting is Sheet, however, you have to change it to Workbook whenever you want to search all worksheets. Excel does not provide a built-in setting that permanently makes Workbook the default. The two methods below offer practical alternatives: run a VBA macro that searches and replaces across the current workbook, or set Active Workbook as the default scope in Kutools for Excel.

In this tutorial:

Which method should you use?

The VBA method runs a separate whole-workbook replacement, while Kutools lets you save a default scope for its Find and Replace pane.

SituationRecommended methodWhy
Run an exact-match replacement across the entire workbookVBASearches every worksheet without an additional tool, but must be run manually and does not change Excel's built-in Find default.
Use Active Workbook as the default Find and Replace scopeKutools for ExcelSaves the scope for its pane and still lets you switch to selected sheets or multiple open workbooks when needed.

Search and replace the entire workbook with VBA

Excel does not offer a direct way to make Workbook the permanent default in its Find and Replace dialog. As a workaround, the following macro searches every worksheet in the workbook containing the code and replaces cells whose entire contents match the search value.

  1. Press Alt + F11 to open the Microsoft Visual Basic for Applications window.
  2. Click Insert > Module, and paste the following code into the module window.

    VBA code: Search and replace the entire workbook

    Sub FindReplace_WB()
        'Updated by Extendoffice
        Dim ws As Worksheet
        Dim xFind As Variant
        Dim xRep As Variant
    
        xFind = Application.InputBox("Find what", "Find and Replace in Workbook", Type:=2)
        If VarType(xFind) = vbBoolean Then Exit Sub
        If xFind = "" Then
            MsgBox "Please enter a value to find.", vbInformation, "Find and Replace in Workbook"
            Exit Sub
        End If
    
        xRep = Application.InputBox("Replace with", "Find and Replace in Workbook", Type:=2)
        If VarType(xRep) = vbBoolean Then Exit Sub
    
        Application.ScreenUpdating = False
        On Error GoTo CleanUp
        For Each ws In ThisWorkbook.Worksheets
            ws.UsedRange.Replace What:=CStr(xFind), Replacement:=CStr(xRep), _
                LookAt:=xlWhole, SearchOrder:=xlByRows, MatchCase:=False
        Next ws
    
    CleanUp:
        Application.ScreenUpdating = True
    End Sub
    
  3. Press F5 to run the macro. In the two dialog boxes that appear, enter the text to find and the replacement text.
    Enter the find and replacement values in the VBA prompts
  4. Click OK. Exact matches across all worksheets in the workbook are replaced.
  5. Save the file as an Excel Macro-Enabled Workbook (*.xlsm). The next time you open it, run the macro again whenever you need to search and replace the entire workbook.

📝 Notes:

  • The macro uses LookAt:=xlWhole, so it replaces only cells whose entire contents match the search value.
  • Changes made by a macro normally cannot be undone with Ctrl + Z. Save a backup before running it on important data.

Set the default search scope to the active workbook with Kutools for Excel

The Navigation pane in Kutools for Excel provides a direct setting for the default Find and Replace scope. Set it to Active Workbook when you normally work within one file; you can still switch to a worksheet, selected sheets, or multiple open workbooks when needed.

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Integrated with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

After installing Kutools for Excel, follow these steps:

  1. Click Kutools > Navigation.
    Open the Navigation pane in Kutools for Excel
  2. In the Navigation pane, click the Navigation Options button button to open Navigation Options. Under Find and Replace, set the default scope to Active Workbook, and then click OK.
    Set Active Workbook as the default Find and Replace scope
  3. In the Navigation pane, click the Find and Replace button button to open Find and Replace. Then complete the replacement as follows:
    Find and replace text in the active workbook
    1. Confirm that Within is set to Active Workbook.
    2. On the Replace tab, enter the search text in Find what and the replacement text in Replace with.
    3. Click Replace All to replace the matching text throughout the active workbook.

    Free Download Kutools for Excel Now!

  4. From now on, the Kutools Find and Replace pane uses Active Workbook as its default scope when you open it.

Frequently Asked Questions

Can I make Workbook the permanent default in Excel's built-in Find and Replace dialog?

No. Excel lets you choose Sheet or Workbook in the Within list, but it does not provide a permanent default-scope setting.

Does the VBA macro change the scope used by Ctrl + F or Ctrl + H?

No. It performs its own replacement across every worksheet in the workbook containing the macro. It does not change Excel's built-in Find and Replace settings.

Why does the macro ignore text that appears inside a longer cell value?

The code uses LookAt:=xlWhole, which matches the entire cell. To replace partial matches instead, change it to LookAt:=xlPart.

Can I undo replacements made by the VBA macro?

Usually not with Ctrl + Z. Save the workbook or create a backup before running the macro.

Can Kutools search more than the active workbook?

Yes. You can change the scope when needed to search selected worksheets, specific open workbooks, or all currently open workbooks.

Best Office Productivity Tools

🤖Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions…
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |  Round without Formula ...
Super Lookup: Multiple Criteria VLookup  |   Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |  Big Formula Bar   |  Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells   |  Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets:  12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

ExcelWordOutlookTabsPowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in