+ Reply to Thread
Results 1 to 10 of 10

Can I use LEFT function in VLOOKUP?

Hybrid View

  1. #1
    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: Can I use LEFT function in VLOOKUP?

    It will work if you extend the lookup range to row 55. It's only 10 at the moment and the value you're looking up is on row 11
    So using vlady's function

    =VLOOKUP(--LEFT(J2,4),'Area Codes'!A1:B100,2,FALSE)
    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.

  2. #2
    Forum Contributor
    Join Date
    06-22-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    152

    Re: Can I use LEFT function in VLOOKUP?

    Fantastic. thank you both. Can I ask what the '--' does?

  3. #3
    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: Can I use LEFT function in VLOOKUP?

    Quote Originally Posted by greyscale View Post
    Fantastic. thank you both. Can I ask what the '--' does?
    Hi,

    With the data you're using the lookup table contains numbers. Even though the number you're using to look up is itself a number, when you extract the leftmost four characters the four characters are treated as a string of text. Hence a straightforward VLOOKUP() would return an error.

    The '--' is what's known as a double unary operator, (no don't ask me!) and using this converts a text string to a number. You see it used a lot in SUMPRODUCT() functions. Think of it as a double minus mathematical operator which is forcing a calculation.

    You could just as easily use
    =VLOOKUP(VALUE(LEFT($J$2,4)),'Area Codes'!A1:B100,2,FALSE)
    since the VALUE() function effectively performs the same function and converts a string to a number value.

    Regards

+ 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