+ Reply to Thread
Results 1 to 6 of 6

Match array of variable strings to the beginning only of a variable length cell

  1. #1
    Registered User
    Join Date
    07-17-2008
    Location
    Kidderminster
    Posts
    18

    Exclamation Match array of variable strings to the beginning only of a variable length cell

    Hello all,

    This one has been driving me nuts so I'm hoping somebody can shed some light on this one for me as I've done a few days banging my head against the desk.

    I've tried using the search function, however it fails (only working in one cell ?) when I use it across sheets (i.e. the array of strings is on another sheet to the cells if testing) and I can't get other functions to check if string begins with variable string, they all check to see if it contains the string anywhere.

    So, lets say I have the following list of strings;

    IP-HAB
    MX-
    TRNS
    PQA-
    IZ-GHS
    CF-DUB
    CR-XC
    QI-NB

    I want to check each cell using a function that only looks at the beginning of the string - i.e. it much find a match at the start of the cell only for any of those strings to be valid or true.

    Any ideas please as I've run into a brick wall.

    Many thanks in advance.

  2. #2
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: Match array of variable strings to the beginning only of a variable length cell

    Does this get you close? I put a string in D2 that I want to search for. C3 is the beginning of my list. This will look at C3 and look to see if the first part of it matches D2.
    Please Login or Register  to view this content.
    Some people volunteer in soup kitchens or hospitals. I choose to make the world better by trying to help you with Excel. We're all learning.

    <---Click * Add Reputation for all helpful comments. It's like giving a smile.
    Forum Rules: How to mark your post [Solved] and have a happier, Excel enriched life.

  3. #3
    Registered User
    Join Date
    07-17-2008
    Location
    Kidderminster
    Posts
    18

    Re: Match array of variable strings to the beginning only of a variable length cell

    Thanks for replying nigelbloomy.

    What I'm looking for is a way to compare all variable length strings in the list above (an array) to the beginning only of a variable length cell.
    Can your solution do that ?

    THIS IS MY LIST OF VARIABLES TO CHECK IF ANY APPEAR AT THE BEGINNING OF THE CELL IF CHECKING

    A1 = IP-HAB
    A2 = MX-
    A3 = TRNS
    A4 = PQA-
    A5 = IZ-GHS
    A6 = CF-DUB
    A7 = CR-XC
    A8 = QI-NB

    B1 = Cell to check
    B2 = Cell to check
    ... and so on

    So if either strings in A1, A2, A3, A4, A5, A6, A7 or A8 appear at the beginning ONLY of a cell (i.e. B1 or B2) then return true or some other value in column C.

    C1 = Check result
    C2 = Check result
    ... and so on

    Hope I did a better job of explaining.

    Thanks again!
    Last edited by nisiwi; 06-17-2015 at 03:51 PM.

  4. #4
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: Match array of variable strings to the beginning only of a variable length cell

    Does this do what you are looking for?

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-17-2008
    Location
    Kidderminster
    Posts
    18

    Re: Match array of variable strings to the beginning only of a variable length cell

    Marvellously simple nigelbloomy!
    Thank-you kind sir.

    Just so that I understand;

    SUMPRODUCT >0 is essentially looking for a match - i.e. 1 or TRUE
    using "--" operator enables SUMPRODUCT to evaluate across the array
    for each variable in the array we compare it (B1,LEN(A1:A8))=A1:A8 against the correct number of characters from the start of the string we are evaluating LEFT(B1,LEN(A1:A8))

    is that about right ?

  6. #6
    Valued Forum Contributor nigelbloomy's Avatar
    Join Date
    11-06-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    1,011

    Re: Match array of variable strings to the beginning only of a variable length cell

    Yes. It takes the cell you are looking at (B1) and creates an array of trimmed down values using all of the lengths of the cells in A1 to A8. Then it compares the values in A1 to A8 with those trimmed down values. Matches will become "TRUE" and those that don't match will become "FALSE." The -- turns the true and false statements to 1 or 0. If at least one match is found, the value will be >0 and the whole formula will return True.

+ 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. Replies: 3
    Last Post: 11-21-2012, 03:28 PM
  2. [SOLVED] Excel 2007 : Averaging variable length strings
    By mayj in forum Excel General
    Replies: 2
    Last Post: 06-07-2012, 09:13 AM
  3. Replies: 6
    Last Post: 04-14-2012, 04:07 AM
  4. VBA variable length array help needed
    By Trinidad3 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-12-2010, 06:19 PM
  5. [SOLVED] how do I do a variable length array based on the value in a cell
    By Mark Pranger in forum Excel General
    Replies: 1
    Last Post: 01-25-2006, 03:10 AM

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