+ Reply to Thread
Results 1 to 7 of 7

VLOOKUP Zip Code mileage problem

  1. #1
    Registered User
    Join Date
    02-19-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2007
    Posts
    14

    VLOOKUP Zip Code mileage problem

    Ok, I've been working on a formula to calculate straight-line distance between two zip codes.

    It's working well, but I am having a problem getting the formula to work correctly when I try to make the zip code a variable. I'm not sure if using a reference for the first argument in the RIGHT function would cause this or if it's a problem somewhere in the LOOKUP formulas.

    Here is the logic that works so long as the zip code is manually typed into a cell in column D:

    Miles between 2 zip codes (in column E)=
    Please Login or Register  to view this content.
    (The 1.2 is a raw adjustment to get closer to driving miles)

    Where:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    +
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    My location addresses are in Column C and include Street, City, State, Zip Code. I would to incorporate logic to pull the zip code from this string so I won't have to manually type the zip code into column D. I can use
    Please Login or Register  to view this content.
    too pull this but when I have the RIGHT function in cell D instead of the zip code typed in I get different mileage results in column E and I'm not sure why.

    I know that ideally you want data to be seperated out as much as possible but these locations are generated in csv's by our enterprise system and are updated constantly. There's no easy way to get the zip code in a cell all of it's own without having to type it in due to foreign locations, string lengths, etc...

    Can anyone identify what it is with the RIGHT function that causes my LOOKUPs to function differently? Is there a better way to get the zip code as a variable?
    Last edited by 2Busy; 11-05-2010 at 12:12 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VLOOKUP Zip Code mileage problem

    Try changing TRUE to FALSE in each of the VLOOKUPs for an exact match.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    02-19-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VLOOKUP Zip Code mileage problem

    That doesn't explain why I get different results when using the RIGHT function (which returns the zip code) than when I use the hard-coded zip code.

    I'm only using the TRUE argument to prevent errors atm...

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VLOOKUP Zip Code mileage problem

    So a zip code can approximate to another zip code?

  5. #5
    Registered User
    Join Date
    02-19-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VLOOKUP Zip Code mileage problem

    The zip codes table is sorted. If you've been through a list of zip codes they follow a pattern. 62617 won't be geographically far from 62618. 0 is a mileage return that I will accept. Less than 2hrs transit time is negligible and won't induce layovers.

    Edit: I should make a note as to how the OFFSET function is affecting the calculation.

    The spreadsheet will show a customer name in column B, location in column C if populated by a VLOOKUP formula. Trucks are seperated by a blank row.

    so:

    *blank*
    Customer 1
    Customer 2
    Customer 3
    *blank*
    Customer 1
    Customer 2
    Last edited by 2Busy; 11-05-2010 at 12:28 PM.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,425

    Re: VLOOKUP Zip Code mileage problem

    Can you post an example workbook with a subset of your data to demonstrate what you expect to get and what you actually get?

    It'll save a lot of guesswork.

    And no, I've never wanted or needed to look at a table of zip codes.

    Regards

  7. #7
    Registered User
    Join Date
    02-19-2010
    Location
    Kansas, USA
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: VLOOKUP Zip Code mileage problem

    Quote Originally Posted by TMShucks View Post
    Can you post an example workbook with a subset of your data to demonstrate what you expect to get and what you actually get?

    It'll save a lot of guesswork.

    And no, I've never wanted or needed to look at a table of zip codes.

    Regards
    Yes sir will do when I get a moment, hectic day and I want to make sure I don't divulge any information that I shouldn't. Thank You!

+ 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