VBA Macro - Want to search for a string of data

Posted on 2014-08-25
Last Modified: 2014-08-26
I found a piece a VBA code to use as a macro that searches through a folder of excel files to find a file number within a worksheet(s) in the folder.  However, this code requires you to match the file number exactly.  Can somebody look at the attached and change it so it will find a string of data within the sheets?  Basically looking to change it from fileNumber = "" to fileNumber Like "" or fileNumber contains "".

Question by:RavenTim
    LVL 47

    Accepted Solution


    to look if a cell contains  change  xlWhole to xlPart

            testWS.Cells.Find(What:=fileNum, After:=ActiveCell, _
             LookIn:=xlFormulas, LookAt:=xlPart, _
             SearchOrder:=xlByRows, SearchDirection:=xlNext, _
             MatchCase:=False, SearchFormat:=False)


    Author Comment

    Awesome!  Works great!  Thanks Rgonzo1971!!

    Author Closing Comment

    Works great!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Unlike scripting languages such as C# where a semi-colon is used to indicate the end of a command, Microsoft's VBScript language relies on line breaks to determine when a command begins and ends. As you can imagine, this quickly results in messy cod…
    Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now