+ Reply to Thread
Results 1 to 6 of 6

Calculate distance between multiple locations using latitude and longitude

  1. #1
    Forum Contributor
    Join Date
    01-06-2015
    Location
    london,uk
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2307) 64-bit....Windows 10 Enterprise
    Posts
    118

    Calculate distance between multiple locations using latitude and longitude

    Hi,

    Could you please help with the below:

    Summary

    Attached you will find an excel workbook containing two tabs (attached). The first tab is titled 'Area' and the second is titled ' Formulas'. The First table contains three tabs titled latitude, longitude and location. The second is titled 'Formulas' and contains the Haversine formula for determining how to calculate the distance between two locations. See B7 for the output calculation. H3-I4 are supporting calculations.

    Problem

    I would like helping creating a tab containing a matrix using macros which can calculate the distance between any of the two locations indicated in the Area tab. Happy to use the output in miles (B8).

    My failed attempt

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by chris1089; 11-06-2023 at 01:52 PM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,883

    Re: Calculate distance between multiple locations using latitude and longitude

    Please Login or Register  to view this content.


    I sorted "Locations" (was "Area") by column C and pasted locations down column A and across Row 1

    Run "CalculateDistances"
    Attached Files Attached Files
    Last edited by JohnTopley; 11-06-2023 at 01:01 PM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Contributor
    Join Date
    01-06-2015
    Location
    london,uk
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2307) 64-bit....Windows 10 Enterprise
    Posts
    118

    Re: Calculate distance between multiple locations using latitude and longitude

    Yes please

    I would like to use the output for an optimisation exercise using solver and macros as a final output.

    I intend to create an additional column next to each location titled availability which picks up if an area is under or over utilised. Those areas under utilised will have <100% utilisations and vice versa. The intention is to resign availability based on the distance between location which is why I need the grid or matrix. I'm hoping to finally create a macro which can use solver and the location grid to determine the idea reallocation of resources.

    for example, area A is only 5 miles away from area B. Area A is under utilised by 95% while area B is over utilised by 105%, therefore as they are within 5 miles the macro will recommend to allocate 5% from area B to area A.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,883

    Re: Calculate distance between multiple locations using latitude and longitude

    See updated post #2
    Last edited by JohnTopley; 11-06-2023 at 01:14 PM.

  5. #5
    Forum Contributor
    Join Date
    01-06-2015
    Location
    london,uk
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2307) 64-bit....Windows 10 Enterprise
    Posts
    118

    Re: Calculate distance between multiple locations using latitude and longitude

    Awesome, this is exactly what i was looking for. Thank you so much. I've added an additional column with sample figures in the column titled utilisation. Is it possible to build a macro using solver to determine the best way to reallocate optimally. For example, I would like the tool to identify locations within 5 miles which have imbalanced utilisation so that these can be relocated accordingly.

    For example location A and B are within 5 miles. Location A has 105 while location B in at 95. Therefore i'd like solver/macro to reallocate 5 from location A to location B so that both are at 100%.

    The recommendation can be in a new column. Is this possible? Apologies, not sure if i need to start a new thread. Happy to close this one as solved before asking the extension question.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,883

    Re: Calculate distance between multiple locations using latitude and longitude

    I have no experience of SOLVER but hopefully those who have will respond.

    As this is a new requirement, I think it will be allowable to start a new thread but ensure the title aptly describes your problem.

+ 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] Excel Spreadsheet to Calculate Endpoint Given Distance, Bearing, and Latitude/Longitude
    By RonnyAtLarge in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-22-2021, 04:35 AM
  2. Distance between latitude and longitude
    By fazna ali in forum Excel General
    Replies: 2
    Last Post: 11-06-2012, 05:03 AM
  3. Distance Formula for Latitude and Longitude
    By dankappa in forum Excel General
    Replies: 4
    Last Post: 11-06-2012, 01:50 AM
  4. Determining distance using Latitude & Longitude
    By KeithRoberts in forum Excel General
    Replies: 2
    Last Post: 03-21-2012, 02:59 PM
  5. Calculate distance of latitude/longitude points
    By sanlen in forum Excel General
    Replies: 5
    Last Post: 12-08-2010, 01:03 AM
  6. Determining Distance from Latitude and Longitude
    By morchard in forum Excel General
    Replies: 3
    Last Post: 01-24-2006, 08:45 PM
  7. [SOLVED] Can distance be calculated using latitude and longitude?
    By Paxton in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-02-2005, 10:06 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