Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

 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 20160913
    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 200 handy Excel add-ins, free to try with no limitation in 60 days.  Free download Kutools for Excel now! 

After installing Kutools for Excel, please do as follows:

1. Click Kutools >Navigation, see screenshot:

doc search workbook 2

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 200 functions can make your job efficiently,you can download Kutools for Excel for free trail.


Recommended Productivity Tools for Excel

kte tab 201905

Kutools for Excel Helps You Always Finish Work Ahead of Time, and Stand Out From Crowd

  • More than 300 powerful advanced features, designed for 1500 work scenarios, increasing productivity by 70%, give you more time to take care of family and enjoy life.
  • No longer need memorizing formulas and VBA codes, give your brain a rest from now on.
  • Become an Excel expert in 3 minutes, Complicated and repeated operations can be done in seconds, 
  • Reduce thousands of keyboard & mouse operations every day, say goodbye to occupational diseases now.
  • 110,000 highly effective people and 300+ world-renowned companies' choice.
  • 60-day full features free trial. 60-day money back guarantees. 2 years of free upgrade and support.

Brings Tabbed Browsing and Editing to Microsoft Office, Far More Powerful Than The Browser's Tabs

  • Office Tab is designed for Word, Excel, PowerPoint and Other Office Applications: 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!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.