Complex Distance Formula

dkoucky

New Member
Joined
Dec 12, 2016
Messages
10
Hi,

I am trying to find the nearest distance between many points. I have a set of about 300 coordinates that I am comparing to a list of about 4k coordinates. I am using the formula:

=IFERROR(ACOS(COS(RADIANS(90-VLOOKUP(V2,dist,4,FALSE)))*COS(RADIANS(90-O2))+SIN(RADIANS(90-VLOOKUP(V2,dist,4,FALSE)))*SIN(RADIANS(90-O2))*COS(RADIANS(VLOOKUP(V2,dist,5,FALSE)-P2)))*3959,99999999999)

The cells are explained below:

=IFERROR(ACOS(COS(RADIANS(90-LATITUDE 1)))*COS(RADIANS(90-LATITUDE 2))+SIN(RADIANS(90-LATITUDE 1)))*SIN(RADIANS(90-LATITUDE 2))*COS(RADIANS(LONGITUDE 1)-LONGITUDE 2)))*3959,99999999999)

This seems to work fine if comparing the list of 4k against the 300 but if I flip it around it just returns somewhat random numbers mostly 1 and 6, I assume this is somehow limited to the first x number of references? Is there another formula I can run or should I do this outside of excel?

Thanks!
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
What do you mean by "flip it around"? Please explain your setup for 4K vs 300 and 300 vs 4K.
 
Upvote 0

Forum statistics

Threads
1,213,510
Messages
6,114,044
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top