+ Reply to Thread
Results 1 to 5 of 5

Lookup table with inconsistent number of leading zeros

  1. #1
    Registered User
    Join Date
    02-10-2011
    Location
    Canada
    MS-Off Ver
    Excel 2019 / MS365
    Posts
    55

    Lookup table with inconsistent number of leading zeros

    I have a lookup table in which the lookup column is composed of product codes. The codes are inconsistent in length, and contain inconsistent numbers of leading zeros. There is a second list of product codes which is used as lookup values, to compare with the first table. The second list also contains inconsistent numbers of leading zeros, and does not necessarily match the syntax of the first list.
    How can I find a match between the two product code columns, when the number of zeros does not match? I have tried the VALUE function, but that seems to work only on the lookup value - I cannot get it to work on the lookup table.
    Attached Files Attached Files
    Last edited by pinebush; 11-24-2017 at 09:12 AM.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Lookup table with inconsistent number of leading zeros

    Use this formula to convert the various forms to "0001" form. Paste this in D3 and copy down to see results:
    Please Login or Register  to view this content.
    SUBSTITUTE strips off the hyphens, then TEXT formats what's left to 4 digits, including leading zeros.
    Last edited by leelnich; 11-23-2017 at 04:41 PM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  3. #3
    Registered User
    Join Date
    02-10-2011
    Location
    Canada
    MS-Off Ver
    Excel 2019 / MS365
    Posts
    55

    Re: Lookup table with inconsistent number of leading zeros

    That helps with the consistency in the lookup table, but does not address the inconsistency problem in the second list, which is often imported from an external source (and a dirty one at that). I guess I could use the same formula in a helper column, to work with the lookup value, but... I was really hoping that I could do this without helper columns.

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Lookup table with inconsistent number of leading zeros

    Paste this in G4 and copy down. (You also need to format the cells as currency):
    Please Login or Register  to view this content.
    This strips the hyphens AND the leading zeros, leaving numbers for the lookup (faster than text). These formulas demonstrate the general principles. For anything more involved, we'd have to see a complete sampling of your actual data.
    Last edited by leelnich; 11-24-2017 at 12:16 AM.

  5. #5
    Registered User
    Join Date
    02-10-2011
    Location
    Canada
    MS-Off Ver
    Excel 2019 / MS365
    Posts
    55

    Re: Lookup table with inconsistent number of leading zeros

    Thanks so much, leelnich. That does exactly what it is supposed to do, without the need of helper column(s). 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. leading zeros and retain number after rid of decimal
    By laundry in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-24-2017, 05:28 AM
  2. [SOLVED] Increase number with leading zeros
    By XLVBA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-19-2015, 10:33 AM
  3. [SOLVED] Adding leading zeros to a number in excel
    By northcoms in forum Excel General
    Replies: 2
    Last Post: 07-04-2013, 09:00 AM
  4. Formatting a Number with leading zeros
    By btamulis in forum Excel General
    Replies: 7
    Last Post: 02-11-2012, 12:09 PM
  5. Add varying number of leading zeros
    By santaklawze in forum Excel General
    Replies: 2
    Last Post: 09-29-2010, 10:47 AM
  6. Spliting a number with leading zeros
    By haitch2 in forum Excel General
    Replies: 7
    Last Post: 09-29-2005, 07:09 PM
  7. [SOLVED] Lookup returns #NA when search value (text) has leading zeros.
    By M-Dickey in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-10-2005, 06:06 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