+ Reply to Thread
Results 1 to 3 of 3

Excel Calculating Distance between two points.

Hybrid View

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    england
    MS-Off Ver
    2013
    Posts
    78

    Excel Calculating Distance between two points.

    Hi All,

    Trying to create an easy to use function in VBA from the complicated formula below.

    but i cant seem to get it working? Any help be much appreciated!

    =IFERROR(6371*ACOS(COS(RADIANS(90-Lat1)) *COS(RADIANS(90-Lat2)) +SIN(RADIANS(90-Lat1)) *SIN(RADIANS(90-Lat2)) *COS(RADIANS(Long1-Long2))),0)

    Function CROWFLIES(dlat1 As Variant, dlat2 As Variant, dlon1 As Variant, dlon2 As Variant)
           
        Pi = 3.1415
        
        Rads = Pi / 180
        
        Acos1 = Application.WorksheetFunction.Acos(Argument)
        
        Errorcheck = Application.WorksheetFunction.IfError(Arg1, Arg2)
    
        CROWFLIES = Errorcheck(6371 * (Acos1(Cos(Rads(90 - dlat1))) * (Cos(Rads(90 - dlat2)) + Sin(Rads(90 - dlat1))) * (Sin(Rads(90 - dlat2))) * (Cos(Rads(dlon1 - dlon2)))), 0)
        
    End Function

  2. #2
    Registered User
    Join Date
    02-20-2014
    Location
    Wales
    MS-Off Ver
    Excel 2010
    Posts
    87

    Re: Excel Calculating Distance between two points.

    Just to clarify... are you trying to work out distance between two Lat/Long points? If so, why not save some time and use something like the Google API - it is free and simple to implement to calculate distance.

  3. #3
    Registered User
    Join Date
    06-23-2014
    Location
    england
    MS-Off Ver
    2013
    Posts
    78

    Re: Excel Calculating Distance between two points.

    Yeah thats correct. Using Longitude and Latitude.

    The issue is the sheer volume of points i would need to analyse a formula actually works out easier for the type of analysis i require

+ 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. Replies: 1
    Last Post: 08-27-2014, 04:30 PM
  2. Calculating Angle and Distance from 3D points (x,y,z)
    By frowny in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-09-2014, 10:33 PM
  3. [SOLVED] Calculating distance between many GPS points and sorting by distance
    By jackalek in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-14-2014, 08:27 AM
  4. [SOLVED] Calculating Distance between 2 points.
    By isdouble in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-20-2012, 07:17 AM
  5. Cumulative distance between intercept points on Excel graphs
    By stubroad in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-07-2009, 12:35 PM

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