+ Reply to Thread
Results 1 to 8 of 8

Lookup "Backwards" Partial Match

  1. #1
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Lookup "Backwards" Partial Match

    Don't know if this is possible or not. I've played around a bit, so far with no success!
    I am trying to create a formula to match credit card charges to related vendor codes, based on the charge description in the credit card transactions data. I have a table of descriptions with matching vendor codes.

    Problem: I would like to be able to do partial "backward" matches, if an exact match for a description is not found. For example, charges from Chevron should be matched to their vendor code. But the actual descriptions will be like: "CHEVRON SUNNYVALE CA", "CHEVRON 1234 MAIN ST OMAHA NE", "CHEVRON CITY CENTER RICHMOND VA", etc.
    I would like for my lookup table to contain a single entry for "CHEVRON", and set up a formula for matching the descriptions, such that any description where the first 7 characters match "CHEVRON" will match to that related vendor code. This is "backwards" because normally you could do a partial lookup on the "short" entry (with a wildcard) to find the first "long" match in the lookup list. But I'm trying to lookup the "long" entry and find the "short" match for it.

    The problem is, the length of the lookup string will vary, because the length of my "short" lookup table entries is not constant. "CHEVRON" is 7 characters, but "EXXON" is 5, "AT&T" is 4, "Amazon" is 6, etc.
    So basically, the lookup needs to look for a match where the first X characters of the lookup value exactly match a table entry whose length is X (and where X can be different for each table entry). I do have a helper column set up that contains the lengths of each of the table entries.

    I've played around with an array formula something like:
    Please Login or Register  to view this content.
    but obviously this doesn't work because array formulas need to be some kind of SUM, MAX, etc. And MAX of the above doesn't work since the vendor codes are text values, not numbers.

    Is there any way to set up a formula that can look up "CHEVRON SUNNYVALE CA" and match it to "CHEVRON", or look up "AT&T MOBILE" and match it to "AT&T", etc.? I've attached an example showing what I want to do.
    Attached Files Attached Files
    Last edited by Merf; 06-15-2021 at 11:00 PM. Reason: Add example file

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Lookup "Backwards" Partial Match

    Attach a sample worksheet. See instruction at top of page in yellow banner.
    Quang PT

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Lookup "Backwards" Partial Match

    In C3 then copied down.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Lookup "Backwards" Partial Match

    Thanks for that solution!
    I'm running Excel 2007, and AGGREGATE was not introduced until Excel 2010, so it looks like I may have to upgrade!

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Lookup "Backwards" Partial Match

    No need to spend anything yet!! Use this instead...


    =IFERROR(INDEX(Setup!$D$3:$D$10,MATCH(1,INDEX(--(ISNUMBER(SEARCH(Setup!$B$3:$B$10,$B3))),0),0)),"")

    copied down.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  6. #6
    Forum Contributor
    Join Date
    03-26-2015
    Location
    Cookeville, TN
    MS-Off Ver
    Excel 365
    Posts
    202

    Re: Lookup "Backwards" Partial Match

    Even better!! THANKS!

  7. #7
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,053

    Re: Lookup "Backwards" Partial Match

    You're welcome & thanks for the feedback.

  8. #8
    Registered User
    Join Date
    01-22-2023
    Location
    Internetland
    MS-Off Ver
    All
    Posts
    1

    Re: Lookup "Backwards" Partial Match

    I've been searching for a formula like this for years. Thank you to the OP for clearly stating the same predicament and for Glenn's solution, much 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. Replies: 3
    Last Post: 11-19-2020, 08:30 PM
  2. use index match for partial/part or after ":" character
    By raj soni in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2017, 12:34 PM
  3. Replies: 2
    Last Post: 07-24-2017, 02:19 AM
  4. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  5. [SOLVED] Multiple criteria lookup - First match :exact" and second match "Closest"
    By mweichorn in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2013, 12:14 PM
  6. SUMPRODUCT with "*" partial string lookup
    By timjames in forum Excel General
    Replies: 8
    Last Post: 09-02-2011, 08:54 AM
  7. How to "match" partial file name
    By BEEJAY in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2006, 11:35 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