Excel VBA need help Searching specific text in WORKBOOKs(not in files name) in sub folders from this code:

Hello, i would need some help to make that code search specific text in excel files(not in the files name but in  the workbook) in folders and sub-folders. I finded that code on a website. Everything work exept it dont search excel files in sub folders. Only search excel file in direct folder even if it had sub-folders with other excel files in it. I tried a lot of code to put in and try to search in sub-folders but nothing work. Can someone help me on that?

Its not to search specific text in excel files name but in  the files itself.

Thx in advance.

Here the original code without modification:

    Sub SearchFolders()
    Dim fso As Object
    Dim fld As Object
    Dim strSearch As String
    Dim strPath As String
    Dim strFile As String
    Dim wOut As Worksheet
    Dim wbk As Workbook
    Dim wks As Worksheet
    Dim lRow As Long
    Dim rFound As Range
    Dim strFirstAddress As String

    On Error GoTo ErrHandler
    Application.ScreenUpdating = False

    ‘Change as desired
    strPath = “c:MyFolder”
    strSearch = “Specific text”

    Set wOut = Worksheets.Add
    lRow = 1
    With wOut
        .Cells(lRow, 1) = “Workbook”
        .Cells(lRow, 2) = “Worksheet”
        .Cells(lRow, 3) = “Cell”
        .Cells(lRow, 4) = “Text in Cell”
        Set fso = CreateObject(“Scripting.FileSystemObject”)
        Set fld = fso.GetFolder(strPath)

        strFile = Dir(strPath & “*.xls*”)
        Do While strFile <> “”
            Set wbk = Workbooks.Open _
              (Filename:=strPath & “” & strFile, _
              UpdateLinks:=0, _
              ReadOnly:=True, _
              AddToMRU:=False)

            For Each wks In wbk.Worksheets
                Set rFound = wks.UsedRange.Find(strSearch)
                If Not rFound Is Nothing Then
                    strFirstAddress = rFound.Address
                End If
                Do
                    If rFound Is Nothing Then
                        Exit Do
                    Else
                        lRow = lRow + 1
                        .Cells(lRow, 1) = wbk.Name
                        .Cells(lRow, 2) = wks.Name
                        .Cells(lRow, 3) = rFound.Address
                        .Cells(lRow, 4) = rFound.Value
                    End If
                    Set rFound = wks.Cells.FindNext(After:=rFound)
                Loop While strFirstAddress <> rFound.Address
            Next

            wbk.Close (False)
            strFile = Dir
        Loop
        .Columns(“A:D”).EntireColumn.AutoFit
    End With
    MsgBox “Done”

    ExitHandler:
    Set wOut = Nothing
    Set wks = Nothing
    Set wbk = Nothing
    Set fld = Nothing
    Set fso = Nothing
    Application.ScreenUpdating = True
    Exit Sub

    ErrHandler:
    MsgBox Err.Description, vbExclamation
    Resume ExitHandler
    End Sub

I searched throught the web and i find nothing to help me, everything i tried dont work and im pretty new to excel.

Its to search in hundred of sub folder, i cant take all sub-folder and make one folder with all excel files because we are a lot of people using these sub-folders.

I need to search specific Persone name in all workbook, not in the files name but in all sheet that the files contain. The code work well but dont search through sub-folders.

thx for your time and help.

By: Tommy

20 thoughts on “Excel VBA need help Searching specific text in WORKBOOKs(not in files name) in sub folders from this code:

  1. ig

    Amazing! This blog looks exactly like my old one!
    It’s on a entirely different subject but it has pretty much the same layout
    and design. Excellent choice of colors!

  2. Lena

    Hi there i am kavin, its my first time to commenting anyplace, when i read this paragraph i thought i
    could also create comment due to this brilliant post.

  3. sling tv

    I’m really enjoying the design and layout of your site.
    It’s a very easy on the eyes which makes it much more pleasant
    for me to come here and visit more often. Did you hire out a developer to create your theme?

    Excellent work!

  4. HectorMow

    [url=http://publica-pr.de/eron-plus-usa/]http://publica-pr.de/eron-plus-usa/[/url]

    Passion the website– really user friendly and great deals to see!

  5. asksylphoflight.tumblr.com sling tv

    You actually make it appear really easy with your
    presentation however I find this matter to be actually something which I feel I
    would by no means understand. It seems too complicated and extremely extensive for me.
    I am taking a look forward for your next publish, I’ll attempt to get the dangle of it!

  6. sling tv

    I do not even understand how I stopped up right here, but I assumed this post was great.
    I do not recognize who you’re however certainly you’re going to a
    well-known blogger when you aren’t already. Cheers!

  7. plenty of fish vs match.com free trial

    I’ve been browsing online more than 4 hours today, yet I never found any interesting
    article like yours. It’s pretty worth enough for me.
    Personally, if all website owners and bloggers made good content as
    you did, the net will be a lot more useful than ever before.

  8. Typicalcat33

    Nice post. I learn something totally new and challenging on sites I stumbleupon everyday. It will always be useful to read through articles from other writers and use something from other sites.

  9. Typicalcat49

    It is actually a great and useful piece of info. I’m happy that you shared this helpful information with us. Please stay us up to date like this. Thank you for sharing.

  10. ps4 games

    Do you have a spam problem on this website;
    I also am a blogger, and I was curious about your situation;
    many of us have developed some nice procedures and we are
    looking to swap techniques with others, please shoot me an email if interested.

  11. quest bars cheap

    Nice post. I learn something new and challenging on websites I
    stumbleupon every day. It’s always exciting to read articles from other authors
    and use something from their sites.

  12. ps4 games

    Thank you, I’ve recently been looking for information approximately this
    subject for a long time and yours is the best I have discovered till now.
    However, what in regards to the conclusion? Are you certain about
    the source?

  13. quest bars cheap

    Thanks for some other informative web site. The place else may I am getting that kind
    of info written in such an ideal manner? I’ve a project that I am just now running on, and I’ve been on the glance out for such info.

  14. http://tinyurl.com/quest-bars-cheap-39003

    Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You obviously know what youre talking about, why waste your
    intelligence on just posting videos to your site when you
    could be giving us something enlightening to read?

Comments are closed.