+ Reply to Thread
Results 1 to 17 of 17

Minimum distance between points

  1. #1
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Minimum distance between points

    Hi!

    Hi can't seem to make this work and I wouldn't like to use VBA to solve this because I believe that built-in functions can do the trick.

    I want to know the minimum distance between customers that I visited in each day.

    If i visit customer 1, 2 and 5 in one day, which distance is smaller? 1-2, 2-5 ou 1-5 and what is the corresponding value?

    I have in columns DATE, CUSTOMER 1, CUSTOMER 2, ..., CUSTOMER 5 and in each row I put the Day and 1 or blank for each customer (visited / not visited). I also have a mileage chart for each customer in another sheet which is the source for my distance data.

    I tried INDEX and MATCH but all I get is ZERO... I think it is comparing the same CUSTOMER.

    Any ideas?

    Thank you in advance!

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Minimum distance between points

    It would be more helpful if you posted your workbook.

  3. #3
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Re: Minimum distance between points

    Here it is.

    thank you
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Re: Minimum distance between points

    Still no contributions?

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Minimum distance between points

    In G2 and down, array-entered: =MIN(IF(B2:F2=1, 'Distance (km)'!B2:F2))

    The formula MUST be confirmed with Ctrl+Shift+Enter, not Enter.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Re: Minimum distance between points

    Thank you for your reply.

    However, I believe you missed the point of the question. Your answer returns the minimum distance of all the points, regardless of where they travel to.

    In the book I uploaded I wrote the correct values to be returned and your formula does not give me that. It's a bit more complicated than that.

    Thank you anyway

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Minimum distance between points

    I think you missed the point of the response. It gives what you say are the correct answers:
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Re: Minimum distance between points

    In day 2, the value should be 18.9. However, your formula returns 3.4.

    And your formula returns different values in my sheet (maybe it's my mistake).

    Please notice that both sheets in the book are not similar...

    THank you!

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Minimum distance between points

    You want the shortest distance between any pair of customers visited on a given day?

  10. #10
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Re: Minimum distance between points

    Yes!

    Thank you!

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Minimum distance between points

    OK, I misunderstood the problem, sorry.

    For me, the path of least resistance would be VBA. Someone else may suggest a formula-based solution.

    If the ultimate goal is to solve the traveling salesman problem, it would be simple for these few customers, and exponentially more time consuming for additional points.
    Last edited by shg; 07-24-2009 at 12:33 PM.

  12. #12
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Re: Minimum distance between points

    Ok, for my knowledge I thought that there would be a way using excel formulas...

    I will try VBA then.

    Thank you!

  13. #13
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,009

    Re: Minimum distance between points

    For ease to solve your problem, I use zero to replace -- and blank.

    Sheet2!G2
    Please Login or Register  to view this content.
    Committed with Ctrl+Shift+Enter. copied down.
    You can also see attached.

    Hope this helps,
    windknife
    Attached Files Attached Files

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Minimum distance between points

    Very nicely done, windknife.

  15. #15
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Minimum distance between points

    Great solution Windknife. Well done!

  16. #16
    Forum Contributor
    Join Date
    10-04-2004
    MS-Off Ver
    2013
    Posts
    148

    Re: Minimum distance between points

    Simply overwhelmed...



    THANK YOU!

  17. #17
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,009

    Re: Minimum distance between points

    You are welcome ^_^

    WindKnife

+ 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