+ Reply to Thread
Results 1 to 6 of 6

Search range for multiple strings

  1. #1
    Registered User
    Join Date
    09-21-2012
    Location
    Plymouth, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    10

    Search range for multiple strings

    I have 3 cells that may contain a 3 or 4 character string. I need to search the 3 cells to see if any of them contain any of the following strings; ABC, DEF, GHIJ. Any or all of the 3 cells may be blank or may contain strings different than the three I am looking for.

    I can accomplish this with the attached code. However, in the real application, I must search 5 cells for 9 possibilities and the code seems to get cumbersome.
    Is there a more concise way to accomplish the same thing?

    Thanks for your consideration.
    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Search range for multiple strings

    Multiple ways to do this, a simple Range.Find would also work, but here's an array comparison approach:

    Please Login or Register  to view this content.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Registered User
    Join Date
    09-21-2012
    Location
    Plymouth, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Search range for multiple strings

    Thanks for the reply.

    My code is Option Explicit and I get a Variable not defined error. I tried to declare arr as string but that resulted in a Type mismatch error. When I declare the arr as Variant the code works fine. Do I have to declare arr as Variant ?

    Thanks again.

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Search range for multiple strings

    Please Login or Register  to view this content.
    should work fine

  5. #5
    Registered User
    Join Date
    09-21-2012
    Location
    Plymouth, Massachusetts
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: Search range for multiple strings

    That did work fine!
    Your code is so much simpler than what I had constructed. I will be able to incorporate it nicely into my work.
    Thread marked "Solved".

    Thanks again.

  6. #6
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Search range for multiple strings

    Glad to help. Any reputation points ( the * in the lower left of the posts) is appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Search For Multiple Text Strings
    By jham808 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-19-2015, 12:53 PM
  2. excel formula to search Multiple strings in several columns and return strings
    By krratna123 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-13-2013, 11:20 AM
  3. Replies: 1
    Last Post: 08-13-2013, 08:32 AM
  4. Search range of strings with a range of keywords and highlight matches
    By efillner in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2013, 04:07 PM
  5. Truncate text strings using LEFT and FIND/SEARCH for multiple search terms
    By ngdoherty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-17-2013, 07:51 PM
  6. Replies: 5
    Last Post: 03-29-2012, 04:12 AM
  7. Search for multiple text strings
    By SueWithQuestion in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-10-2011, 09:48 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1