Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Distance Calculation

I already have a VBA Script that calculates distances from lat/long of 2
points (a reference point, then other locations). This type of script is
widely available on the net.

My situation now is that I have a list of 7 locations (each with its own
lat/long). I want to find out how close they are to each other.

With my current script, the only way I can figure this out is to copy the
locations into 7 separate columns to run the script 7 times. That is fine
with a small #, but what about if I have 100 locations?

Any suggestions?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Distance Calculation

Just build a loop to do it, I just today completed that very thing. If you
create a function that does your calculations and just send the numbers it is
very fast. Mine looks at the location of 300 drivers, compares their location
to the lat long I provided, gets the distance and finds the 6 closest, runs
in under 2 seconds. And this machine is junk. If you can build a function and
an array you are set. This is the function we use, i pass in the driver
lat/long and the location lat/long and it returns a result that I do a little
more math on
Public Function calcDistance(destLat, driverLat, destLong, driverLong)
calcDistance = Math.Sqr(((destLat - driverLat) ^ 2) + (destLong -
driverLong) ^ 2)
End Function
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"JSpence2003" wrote:

I already have a VBA Script that calculates distances from lat/long of 2
points (a reference point, then other locations). This type of script is
widely available on the net.

My situation now is that I have a list of 7 locations (each with its own
lat/long). I want to find out how close they are to each other.

With my current script, the only way I can figure this out is to copy the
locations into 7 separate columns to run the script 7 times. That is fine
with a small #, but what about if I have 100 locations?

Any suggestions?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Distance Calculation

That sounds like the script I already have. Where it will plot the distance
between 2 points given you have an origin point and a destination point.

The situation I have now is a list of 7 stores, I want to know how close
they are to each other.

e.g. (store 1 is 5 miles from store 2, 7 miles from store 3, etc)

Jason

"John Bundy" wrote:

Just build a loop to do it, I just today completed that very thing. If you
create a function that does your calculations and just send the numbers it is
very fast. Mine looks at the location of 300 drivers, compares their location
to the lat long I provided, gets the distance and finds the 6 closest, runs
in under 2 seconds. And this machine is junk. If you can build a function and
an array you are set. This is the function we use, i pass in the driver
lat/long and the location lat/long and it returns a result that I do a little
more math on
Public Function calcDistance(destLat, driverLat, destLong, driverLong)
calcDistance = Math.Sqr(((destLat - driverLat) ^ 2) + (destLong -
driverLong) ^ 2)
End Function
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"JSpence2003" wrote:

I already have a VBA Script that calculates distances from lat/long of 2
points (a reference point, then other locations). This type of script is
widely available on the net.

My situation now is that I have a list of 7 locations (each with its own
lat/long). I want to find out how close they are to each other.

With my current script, the only way I can figure this out is to copy the
locations into 7 separate columns to run the script 7 times. That is fine
with a small #, but what about if I have 100 locations?

Any suggestions?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Distance Calculation

Sounds like you are on the right path if you are feeding the information into
an array, if you're not, it will take a LOT longer. What steps are you
needing help with from here or were you just seeing if there was a better way?
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"JSpence2003" wrote:

That sounds like the script I already have. Where it will plot the distance
between 2 points given you have an origin point and a destination point.

The situation I have now is a list of 7 stores, I want to know how close
they are to each other.

e.g. (store 1 is 5 miles from store 2, 7 miles from store 3, etc)

Jason

"John Bundy" wrote:

Just build a loop to do it, I just today completed that very thing. If you
create a function that does your calculations and just send the numbers it is
very fast. Mine looks at the location of 300 drivers, compares their location
to the lat long I provided, gets the distance and finds the 6 closest, runs
in under 2 seconds. And this machine is junk. If you can build a function and
an array you are set. This is the function we use, i pass in the driver
lat/long and the location lat/long and it returns a result that I do a little
more math on
Public Function calcDistance(destLat, driverLat, destLong, driverLong)
calcDistance = Math.Sqr(((destLat - driverLat) ^ 2) + (destLong -
driverLong) ^ 2)
End Function
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"JSpence2003" wrote:

I already have a VBA Script that calculates distances from lat/long of 2
points (a reference point, then other locations). This type of script is
widely available on the net.

My situation now is that I have a list of 7 locations (each with its own
lat/long). I want to find out how close they are to each other.

With my current script, the only way I can figure this out is to copy the
locations into 7 separate columns to run the script 7 times. That is fine
with a small #, but what about if I have 100 locations?

Any suggestions?

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Distance between Forms Grupos de Noticias Excel Programming 1 November 3rd 06 02:09 PM
Minimum Distance Calculation using Array and Geographical Coordinates geobatman Excel Discussion (Misc queries) 1 June 9th 06 10:49 PM
Distance/Time calculation RC Excel Programming 1 February 2nd 06 01:22 PM
time/distance calculation KJO Excel Worksheet Functions 1 April 20th 05 09:13 PM
Distance between zip codes Squid Excel Worksheet Functions 2 March 10th 05 04:27 AM


All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"