[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


VBA Macro - Want to search for a string of data

Posted on 2014-08-25
Medium Priority
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
  • 2
LVL 54

Accepted Solution

Rgonzo1971 earned 2000 total points
ID: 40285345

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

ID: 40285456
Awesome!  Works great!  Thanks Rgonzo1971!!

Author Closing Comment

ID: 40285458
Works great!

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

872 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