+ Reply to Thread
Results 1 to 5 of 5

VBA: Finding Partially Matching Array Values ('Like' Statement)

  1. #1
    Registered User
    Join Date
    04-26-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Business (v 2306 / 16.0) 64-bit
    Posts
    27

    Question VBA: Finding Partially Matching Array Values ('Like' Statement)

    Scenario:
    1. I copy a large group of text to the clipboard
    2. I set said text to a string variable, let's call it RawText
    3. I proceed to perform a split function on RawText, using 'vbCrLf' as the separating factor. This gets placed into an array, let's call it Array1

    There will always be a maximum of 20 separate strings in this array, but often less.

    I would like to use some sort of function that would allow me to extract the entire string of an array if it matches the first part of a string.

    Example:
    Lets say I copy the following text to the clipboard (and then store it under the string RawText).
    ABCD: Apple
    ABBC: Banana
    ACEF: Orange

    Now, I proceed to use split function as such:

    Array1 = Split(RawText,vbCrLf,20)

    The Array1 Values should be: {"ABCD: Apple", "ABBC: Banana", "ACEF: Orange"}

    I would like to use something such as the Like statement and pull out the entire value of the string in the array if it matches, such as:

    Please Login or Register  to view this content.
    which would set MyString = "ABCD: Apple"

    I hope this makes sense, I just need the proper context in how I can go through all the strings in the Array1 and find the one that matches my Like Statement.

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: VBA: Finding Partially Matching Array Values ('Like' Statement)

    May be this UDF would be helful for you
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: VBA: Finding Partially Matching Array Values ('Like' Statement)

    Please Login or Register  to view this content.
    Maybe with an Inputbox is easier.
    Obviously, change all references as required.
    Please Login or Register  to view this content.
    Last edited by jolivanes; 09-09-2016 at 12:23 AM. Reason: Another option

  4. #4
    Registered User
    Join Date
    04-26-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 Apps for Business (v 2306 / 16.0) 64-bit
    Posts
    27

    Re: VBA: Finding Partially Matching Array Values ('Like' Statement)

    +1 for both. Thanks for the assistance

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,527

    Re: VBA: Finding Partially Matching Array Values ('Like' Statement)

    Or if it is not always 4 digits
    Please Login or Register  to view this content.
    Your choice.
    Good luck and thanks for letting us know.

+ 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. matching partially same product names from 2 different sheets
    By sandubandu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-20-2016, 10:35 AM
  2. matching partially same product names from 2 different sheets
    By sandubandu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2016, 03:24 AM
  3. [SOLVED] Identify cells that contain partially matching text?
    By MetroBOS in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-28-2015, 05:31 PM
  4. [SOLVED] Finding matching values from different columns
    By hefe_espada in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-23-2013, 07:24 PM
  5. [SOLVED] finding or matching cell in two dimensional array
    By Alexander_Golinsky in forum Excel General
    Replies: 7
    Last Post: 08-16-2012, 02:51 AM
  6. Finding the Lowest Values and Matching
    By artiststevens in forum Excel General
    Replies: 1
    Last Post: 05-04-2011, 11:45 PM
  7. Finding Matching values in cells
    By Zemmy in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-26-2008, 04:09 PM

Tags for this Thread

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