Skip to main content

How to quickly search a value in multiple sheets or workbooks?

Have you ever imaged to search a certain value in multiple sheets or workbooks in Excel? This tutorial introduces some different methods to solve the problems about searching in multiple sheets or searching in multiple workbooks.

Search a value in multiple sheets of a workbook with Find and Replace function

Search a value in all workbooks of a folder with VBA

Quickly search a value across multiple opened workbooks with Kutools for Excel good idea3


With Excel’s Find and Replace function, you can find a certain value across multiple sheets.

1. Select multiple sheet tabs you want to find value from by holding the Ctrl key and clicking the worksheets in the Sheet Tab bar one by one. See screenshot:

doc search value in multiple sheets 1

2. Then Press Ctrl + F to enable the Find and Replace window, and type the value you want to search in the Find what textbox under Find tab, and then click Find All button to list all the results. See screenshot:

doc search value in multiple sheets 2


Find and replace value across sheets and workbooks

Kutools for Excel's advanced Find and Replace function, can help you find and replace a value across multiple sheets and opened workbooks.  Free Download
find replace
 
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

If you want to search a value in all closed workbooks from a folder, you only can apply a VBA to solve it.

1. Enable a new workbook and select a cell, then press Alt + F11 keys to open Microsoft Visual for Basic Applications window.

2. Click Insert > Module and paste below VBA to the new Module window.

VBA: Search a value across all workbooks of a folder.

Sub SearchFolders()
'UpdatebyKutoolsforExcel20200913
    Dim xFso As Object
    Dim xFld As Object
    Dim xStrSearch As String
    Dim xStrPath As String
    Dim xStrFile As String
    Dim xOut As Worksheet
    Dim xWb As Workbook
    Dim xWk As Worksheet
    Dim xRow As Long
    Dim xFound As Range
    Dim xStrAddress As String
    Dim xFileDialog As FileDialog
    Dim xUpdate As Boolean
    Dim xCount As Long
    Dim xAWB As Workbook
    Dim xAWBStrPath As String
    Dim xBol As Boolean
    Set xAWB = ActiveWorkbook
    xAWBStrPath = xAWB.Path & "\" & xAWB.Name
    On Error GoTo ErrHandler
    Set xFileDialog = Application.FileDialog(msoFileDialogFolderPicker)
    xFileDialog.AllowMultiSelect = False
    xFileDialog.Title = "Select a forlder"
    If xFileDialog.Show = -1 Then
        xStrPath = xFileDialog.SelectedItems(1)
    End If
    If xStrPath = "" Then Exit Sub
    xStrSearch = "KTE"
    xUpdate = Application.ScreenUpdating
    Application.ScreenUpdating = False
    Set xOut = Worksheets.Add
    xRow = 1
    With xOut
        .Cells(xRow, 1) = "Workbook"
        .Cells(xRow, 2) = "Worksheet"
        .Cells(xRow, 3) = "Cell"
        .Cells(xRow, 4) = "Text in Cell"
        Set xFso = CreateObject("Scripting.FileSystemObject")
        Set xFld = xFso.GetFolder(xStrPath)
        xStrFile = Dir(xStrPath & "\*.xls*")
        Do While xStrFile <> ""
            xBol = False
            If (xStrPath & "\" & xStrFile) = xAWBStrPath Then
                xBol = True
                Set xWb = xAWB
            Else
                Set xWb = Workbooks.Open(Filename:=xStrPath & "\" & xStrFile, UpdateLinks:=0, ReadOnly:=True, AddToMRU:=False)
            End If
            For Each xWk In xWb.Worksheets
                If xBol And (xWk.Name = .Name) Then
                Else
                Set xFound = xWk.UsedRange.Find(xStrSearch)
                If Not xFound Is Nothing Then
                    xStrAddress = xFound.Address
                End If
                Do
                    If xFound Is Nothing Then
                        Exit Do
                    Else
                        xCount = xCount + 1
                        xRow = xRow + 1
                        .Cells(xRow, 1) = xWb.Name
                        .Cells(xRow, 2) = xWk.Name
                        .Cells(xRow, 3) = xFound.Address
                        .Cells(xRow, 4) = xFound.Value
                    End If
                    Set xFound = xWk.Cells.FindNext(After:=xFound)
                Loop While xStrAddress <> xFound.Address
                End If
            Next
            If Not xBol Then
            xWb.Close (False)
            End If
            xStrFile = Dir
        Loop
        .Columns("A:D").EntireColumn.AutoFit
    End With
    MsgBox xCount & " cells have been found", , "Kutools for Excel"
ExitHandler:
    Set xOut = Nothing
    Set xWk = Nothing
    Set xWb = Nothing
    Set xFld = Nothing
    Set xFso = Nothing
    Application.ScreenUpdating = xUpdate
    Exit Sub
ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
End Sub

3. Then press F5 key or Run button to execute this VBA, and a Select a folder dialog pops out to remind you to select a folder which you want to search value from. See screenshot:

doc search value in multiple sheets 3

4. And then click OK and another dialog pops out to remind you the number of cells have been found. See screenshot:

doc search value in multiple sheets 4

5. Click OK to close it, and all the found cells are list in the current worksheet with the corresponding information.

doc search value in multiple sheets 5

Tip: In above VBA, you search the value “KTE”, and you can change “KTE” from this xStrSearch = "KTE" to another value as you need.


If you just want to search a value across multiple opened workbooks, you can use Kutools for Excel’s advanced Find and Replace utility.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After free installing Kutools for Excel, please do as below:

1. In one of the opened workbooks, click Kutools > Navigation, and then click the Find and Replace button doc find button to go to Find and Replace pane. See screenshot:

doc search value in multiple sheets 6

2. Then click Find tab, and type the value you want to search in the Find what textbox, and then select All workbooks from the Within dropdown list, and go to click Find All to list all found cells. See screenshot:
doc kutools find replace 2

Tip:

With Kutools for Excel’s advanced Find and Replace utility, you can search and replace value in selected sheets across multiple workbooks, all workbooks, active workbook, active sheet or selection.
doc kutools find replace 3


Relative Articles:

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

Description


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 (18)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
program stops here:

Set xWb = Workbooks.Open(Filename:=xStrPath & "\" & xStrFile, UpdateLinks:=0, ReadOnly:=True, AddToMRU:=False)
This comment was minimized by the moderator on the site
Hi, Mike, I have update the VBA in the article, please try again. If there is any problem, please let me know, thank you.
This comment was minimized by the moderator on the site
HI in my case worksheet with more than 1 Lakhs record, scripts failed.
This comment was minimized by the moderator on the site
Hi, Dhireesh, VBA code has its own limitation. You could try Kutools for Excel's Fiind and Replace, but it may run slowly, please be patience, and had better save the workbooks before.
This comment was minimized by the moderator on the site
How do i create hyperlink under column C for all cell values in the same code?
This comment was minimized by the moderator on the site
como generar códigos qr
This comment was minimized by the moderator on the site
Awesome this works perfect,
Could you help me, I would like to create an hyperlink to each cell where the value was found.

Thanks in advance
This comment was minimized by the moderator on the site
me too I would like! :)
This comment was minimized by the moderator on the site
Perfect for what I need except for the fact that it creates a new sheet every search. How would I modify the code to use a single sheet for each search instead of creating a new one? Thanks, James
This comment was minimized by the moderator on the site
Your code works great, I look for a code that finds two texts in excel files, do you know how is it possible?
This comment was minimized by the moderator on the site
Sorry, I have no idea on this problem, you can go to our forum https://www.extendoffice.com/forum.html to carry on the problem, maybe someone know the answer.
This comment was minimized by the moderator on the site
How can I add another column and bring the value that is always 3 columns to the right on the value found?
This comment was minimized by the moderator on the site
Did you ever figure this out? I need that as well.
This comment was minimized by the moderator on the site
Sorry I cannot help you, you can go to out forum https://www.extendoffice.com/forum.html to carry on the question, maybe someone can help you.
This comment was minimized by the moderator on the site
Thanks. It helped me a lot =)
This comment was minimized by the moderator on the site
This is what i want it to return "Site Instruction" which is allocated to all Text in Cell
Workbook Worksheet Cell Text in Cell Site Instruction
Shift report Emicc 01-10-17.xlsx Sheet1 $D$20 CMS install 1773
Shift report Emicc 01-10-17.xlsx Sheet1 $D$21 CMS install 1763
Shift report Emicc 01-10-17.xlsx Sheet1 $D$24 CMS install 1551
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations