+ Reply to Thread
Results 1 to 5 of 5

VLookup and leading zeros

  1. #1
    Registered User
    Join Date
    12-11-2008
    Location
    Kalamazoo
    Posts
    17

    VLookup and leading zeros

    I have a series of 8 digit numbers each with a related description. Some of them have a leading zero, such as 07119902. However, when I enter the VLookup formula, I get a "n/a".

    The list of numbers and descriptions is on Sheet1, columns A and B. I'm working on Sheet2. The number I'm referencing is in column C. I've been using this formula, =VLOOKUP(C1,Sheet1!A:B,2,0) and it works fine for all numbers except those with the leading zero.

    01000000 Agricultural Production Crops
    01100000 Cash Grains
    01110000 Wheat
    01120000 Rice
    01150000 Corn
    01160000 Soybeans

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: VLookup and leading zeros

    "leading zeros" can be put in as part of the number, or as part of the formatting. Click on the number in Sheet1, column A, and look in the Formula bar. If the number is displayed there without the zero's, then it's a number formatted as text with the leading zeros. Now click in your Column C and do the same thing. I'm willing to bet in one area you have a number formatted as text, and in the other you have a text number, which has the leading zeros in it's values. In other words, on the sheet you might have two numbers that you can see plain as day say "000254". Clicking on each, one shows in the formula bar as "000254", the other as "254". VLookup will return an "N/A" because it can't find a match.

    Depending on which one the problem is, one of the solutions below should work.

    Please Login or Register  to view this content.
    After determining which solution boils out the right answer, you can use IFERROR to apply either solution, like this:
    Please Login or Register  to view this content.
    Last edited by jomili; 01-31-2013 at 11:30 AM. Reason: Forgot a parenthesis

  3. #3
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VLookup and leading zeros

    Your formula does appear to work. See the attached.
    Attached Files Attached Files
    Gary's Student

  4. #4
    Registered User
    Join Date
    12-11-2008
    Location
    Kalamazoo
    Posts
    17

    Re: VLookup and leading zeros

    Converting each to text in the formatting palette took care of the problem without having to adjust my original VLookup formula. Thank you jomili ... just pointing out how each was appearing in the formula bar helped. I think your second formula is missing a )
    Last edited by zloep; 01-31-2013 at 12:51 PM. Reason: Misspelled word

  5. #5
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: VLookup and leading zeros

    Thanks. I edited my original post to correct the second formula. Sorry about that.

+ 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