Skip to main content

How to always search in whole workbook?

Author: Xiaoyang Last Modified: 2020-07-17

In Excel, when you apply the Find and Replace function, it will search in current worksheet by default, if you always want to search in all sheets, you have to change Sheet to Workbook under the Option button in Find and Replace dialog while enable the workbook every time. How could you set it to search within the entire workbook instead of active sheet by default?

Always search in whole workbook with VBA code

Always search in whole workbook with Kutools for Excel

arrow blue right bubble Always search in whole workbook with VBA code

In fact, there is no direct way for us to change the search scope to entire workbook by default in Excel, but, you can apply the following VBA code as a workaround. With this code, you needn’t to change the search scope each time when you lunching this workbook.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module Window.

VBA code: Always search in whole workbook:

Sub FindReplace_WB()
'Updateby Extendoffice
    Dim ws As Worksheet
    Dim xFind As String
    Dim xRep As String
    Application.ScreenUpdating = False
    On Error Resume Next
    xFind = Application.InputBox("Find what", "Kutools for Excel", "", , , , , 2)
    xRep = Application.InputBox("Replace with", "Kutools for Excel", "", , , , , 2)
    If xFind = "" Then
        MsgBox "wrong...", vbInformation, "Kutools for Excel"
        Exit Sub
    End If
    For Each ws In ThisWorkbook.Worksheets
        ws.UsedRange.Replace What:=xFind, Replacement:=xRep, LookAt:=xlWhole
    Next ws
    On Error GoTo 0
    Application.ScreenUpdating = True
End Sub

3. Then press F5 key to run this code, and in the popped out dialog boxes, please type the text values in to the Find what and Replace with boxes separately, see screenshot:

doc search workbook 1

4. And then click OK, all the values in the whole workbook you want have been replaced with the needed values.

5. Please save the workbook as Excel Macro-Enabled Workbook format, and next time, when you open this workbook, you can always apply this code to search in the entire workbook.

arrow blue right bubble Always search in whole workbook with Kutools for Excel

If you have Kutools for Excel, with its Navigation Pane utility, you can always find and replace in a worksheet, whole workbook or multiple opened workbooks as you need.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.  Free download Kutools for Excel now! 

After installing Kutools for Excel, please do as follows:

1. Click KutoolsNavigation, see screenshot:

2. In the Navigation pane, click doc search workbook 4 button to go to the Navigation Options, in the option center, please specify the default scope as you need under the Find and Replace section, in this case, I will select Active workbook, see screenshot:

doc search workbook 3

doc search workbook 5

3. Then click OK button, close and reopen the workbook to take the setting effect, and now, go to the Navigation pane, and click doc search workbook 6 button to activate the Find and Replace function. In the Find and Replace pane, please do the following operations:

(1.) Under the Within section, you can see the default scope has been changed to the Active workbook;

(2.) Under the Replace tab, enter the text you want to find and replace separately into the Find what and Replace with text box;

(3.) Then click the Replace All button to replace the text in active workbook you need.

Click Free Download Kutools for Excel Now!

4. From now on, when you open any workbook and apply this Find and Replace utility of Kutools, the search scope is the active workbook by default.

More than 300 functions can make your job efficiently,you can download Kutools for Excel for free trail.

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

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!
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations