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?
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:
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.
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 Kutools > Navigation, see screenshot:
2. In the Navigation pane, click 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:
3. Then click OK button, close and reopen the workbook to take the setting effect, and now, go to the Navigation pane, and click 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.
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
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!