+ Reply to Thread
Results 1 to 6 of 6

Using LEFT, MID, or RIGHT within VLOOKUP or INDEX/MATCH/MATCH

  1. #1
    Registered User
    Join Date
    01-05-2016
    Location
    Louisville, KY
    MS-Off Ver
    Professional Plus 2010
    Posts
    2

    Angry Using LEFT, MID, or RIGHT within VLOOKUP or INDEX/MATCH/MATCH

    I am trying to lookup or index only part of a cell, but I keep getting an #N/A error.

    When I use VLOOKUP, I want my lookup_value to be only the LEFT 4 characters.
    Alternatively, when I use INDEX/MATCH/MATCH, I want my first MATCH look_up value to be only the LEFT 4 characters.

    I have tried this two ways with both functions: using the LEFT function directly into the other formulas,
    =INDEX('[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$30,MATCH(LEFT(C2,4),'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$A$30,0),MATCH(F2,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$4,0))
    and also creating a column to return the LEFT 4 characters and using that column in my formula.
    *C2 example: 5562-3327* *Formula in D2 =LEFT(C2,4)* =INDEX('[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$30,MATCH(D2,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$A$30,0),MATCH(F2,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$4,0))

    Any way around this? When I physically type in the text (example: 5562) and use that cell in my formula, it works, so the functions are working properly.
    =INDEX('[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$30,MATCH(D2,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$A$30,0),MATCH(F2,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$4,0))

    But when I try use to use LEFT function, it gives me an #N/A error, when using either VLOOKUP or INDEX/MATCH/MATCH functions

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Using LEFT, MID, or RIGHT within VLOOKUP or INDEX/MATCH/MATCH

    If you have the final parameter set to zero in a MATCH function, you are looking for an exact match, but if you are taking the first 4 characters then you will only get an exact match if the lookup range contains those 4 characters. But, you can use a wildcard character, so I think this is what you are trying to do:

    =INDEX('[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$30,MATCH(LEFT(C2,4)&"*",'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$A$30,0),MATCH(F2,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$4,0))

    Hope this helps.

    Pete

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Using LEFT, MID, or RIGHT within VLOOKUP or INDEX/MATCH/MATCH

    Try

    =INDEX('[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$30,MATCH(LEFT(C2,4)*1,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$A$30,0),MATCH(F2,'[Casual Cushion Fabric Grade List Prices.xlsx]Sheet1'!$A$4:$Q$4,0))

    This will convert the 4 characters to number rather than text and the MATCH function should work then
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Using LEFT, MID, or RIGHT within VLOOKUP or INDEX/MATCH/MATCH

    Hi, and welcome to the forum.

    Upload your workbook so that we can see the request in context.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,822

    Re: Using LEFT, MID, or RIGHT within VLOOKUP or INDEX/MATCH/MATCH

    It might be difficult without a sample file to see exactly what is happening.

    A first guess -- the LEFT(C2,4) function will return the text string "5562". The text string "5562" is not the same thing as the number 5562, and lookup functions will often not connect the two. My first guess is that you are facing one of these "numbers stored as text" kind of problems. You will need to look at your lookup value and your lookup table and see if you are searching for text strings or numbers and adapt formulas accordingly.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Registered User
    Join Date
    01-05-2016
    Location
    Louisville, KY
    MS-Off Ver
    Professional Plus 2010
    Posts
    2

    Re: Using LEFT, MID, or RIGHT within VLOOKUP or INDEX/MATCH/MATCH

    Using the *1 to convert the string to a number did the trick!!!! Thank you Ace_XL!

+ 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: 1
    Last Post: 06-18-2015, 08:45 AM
  2. Replies: 2
    Last Post: 12-18-2014, 09:52 AM
  3. Replies: 3
    Last Post: 05-19-2014, 02:01 PM
  4. VLOOKUP/INDEX/MATCH to return all values that match
    By lijia00 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2014, 11:56 AM
  5. Replies: 4
    Last Post: 01-13-2014, 04:16 AM
  6. Replies: 13
    Last Post: 12-13-2012, 11:44 AM
  7. Replies: 2
    Last Post: 03-16-2012, 12:03 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