+ Reply to Thread
Results 1 to 5 of 5

can vlookup look at only the 1st or last few characters?

  1. #1
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    can vlookup look at only the 1st or last few characters?

    I can do a simple vlookup but would like to know if it can look at the last or first few characters... if it is possible then what function would I need to add to the Vlookup so it can look for a specific match on the 1st or last few characters???
    Last edited by jgomez; 11-04-2011 at 11:49 AM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,792

    Re: can vlookup look at only the 1st or last few characters?

    It depends on exactly what you want to match?

    If you use a lookup value of LEFT(A2,1)&"*" within VLOOKUP...

    ...for example then if A2 contains "xyz" that would match with anything beginning with an "x"......or you can use the LEFT part on it's own to match with "x" exactly. You can do the same with RIGHT
    Audere est facere

  3. #3
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: can vlookup look at only the 1st or last few characters?

    I get #N/A. I have 123123 in cell A2 & 12 in cell c2.... this is my formula

    =VLOOKUP(LEFT(C2,2)&"*",A:A,1,FALSE)

  4. #4
    Valued Forum Contributor
    Join Date
    10-13-2010
    Location
    Sunderland, England
    MS-Off Ver
    Excel 2007 (Home) / 2003 (Work)
    Posts
    740

    Re: can vlookup look at only the 1st or last few characters?

    The formula will only work when comparing text. In a numeric sense, the '12' at the start of 121212 is actually 120,000.

    If you convert your numbers to text the formula should work fine.

  5. #5
    Valued Forum Contributor
    Join Date
    12-22-2010
    Location
    Texas
    MS-Off Ver
    Excel 2003 & Excel/Access 2007
    Posts
    438

    Re: can vlookup look at only the 1st or last few characters?

    Thank you both! Adjusted the formula a bit too though

    =VLOOKUP(LEFT(C$1,2)&"*",A1,1,FALSE)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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