Note: The other languages of the website are Google-translated. Back to English
English English

How to always search in whole workbook?

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.

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

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!
officetab bottom
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