+ Reply to Thread
Results 1 to 10 of 10

Driving Miles

Hybrid View

  1. #1
    Registered User
    Join Date
    07-18-2015
    Location
    Las Vegas, NV
    MS-Off Ver
    12
    Posts
    6

    Driving Miles

    I am trying to create a spreadsheet that depending on the Store # I have to drive to, it will insert the number of miles I travel round trip. I drive to approx 50 different stores in my area for work and would like to enter into cell (for example) B4 the store number (example 501) and then in cell C4 it will automatically enter the number of miles that drive is.

    I am using this formula right now but need to add to it and dont know how to connect multiple commands.

    =IF(OR(B4={502,503,504,505}),"30","")

    in that command The Store Numbers 502,503,504 and 505 are 30 miles away but I need to add stores (for example) 506,507,508 that are 40 miles away.

    Any help is appreciated.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,420

    Re: Driving Miles

    I would suggest that you set up a 2-column table somewhere, e.g. in cells X1 to Y50, which has the store numbers in column X and the distances in column Y. Then in C4 you can use the formula:

    =IFERROR(VLOOKUP(B4,X$1:Y$50,2,0),"")

    You might need to add *2 to the VLOOKUP part, if your distances are for a one-way trip.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    07-18-2015
    Location
    Las Vegas, NV
    MS-Off Ver
    12
    Posts
    6

    Re: Driving Miles

    Pete,

    If I do that can I copy and paste in in cells below without it effecting the formula?

    Thanks

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,420

    Re: Driving Miles

    Yes, the B4 will change to B5, B6 etc. when you copy it down, so that you can put other store numbers in those cells, but the table X$1:Y$50 will remain the same in the formula.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    07-18-2015
    Location
    Las Vegas, NV
    MS-Off Ver
    12
    Posts
    6

    Re: Driving Miles

    Pete,

    I am getting a #name? error. I changed the x$1:y$50 to the appropriate cells that are represented in my spreadsheet as I had already created that two columns you suggested.

    Any ideas why I would get that error?

    Thanks

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,420

    Re: Driving Miles

    That error usually means that Excel doesn't recognise a function name or named range that you are trying to use in a formula. There are only two functions in the formula that I gave you - IFERROR and VLOOKUP - have you spelt those correctly. What version of Excel are you using?

    Post the formula that you tried to enter.

    Pete

  7. #7
    Registered User
    Join Date
    07-18-2015
    Location
    Las Vegas, NV
    MS-Off Ver
    12
    Posts
    6

    Re: Driving Miles

    i copied and pasted the formula you posted

    =IFERROR(VLOOKUP(B4,M$4:N$50,2,0),"")

  8. #8
    Registered User
    Join Date
    07-18-2015
    Location
    Las Vegas, NV
    MS-Off Ver
    12
    Posts
    6

    Re: Driving Miles

    Wow..that did it!

    Thank you so much!


+ 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. [SOLVED] Convert miles/mph to time in hh:mm
    By zookeepertx in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-16-2014, 11:23 AM
  2. Replies: 5
    Last Post: 08-30-2013, 04:32 PM
  3. calculate TOTAL mileage (first 2 miles set rate) all miles thereafter set rate
    By infinite2006 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-30-2013, 08:26 AM
  4. Looking up miles between points
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-29-2011, 05:07 PM
  5. Calculating Miles, Distance & MPH
    By avidcat in forum Excel General
    Replies: 2
    Last Post: 07-07-2009, 05:24 PM
  6. Calculate Miles per hour
    By anwittin in forum Excel General
    Replies: 5
    Last Post: 11-03-2006, 05:03 PM
  7. Miles Per Hour
    By WalkerDude999 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-07-2006, 04:42 AM

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