Pulling my hair out trying to get a formula to work (or do ANYTHING)

nigelbradley

New Member
Joined
Sep 13, 2017
Messages
4
Hi all,
I'm trying to work out the distance between two sets of lat/long coords.

After much searching I found the formula at the bottom
When I use it with either numbers instead of lat/longs or the cell reference my PC does absolutely nothing. It doesn't post anything in the cell at all, not even an error.
I've tried breaking it down into the 5 different component calculations and they work individually.:confused::confused::confused:

<tbody>
[TD="class: xl63"]lat1[/TD]
[TD="class: xl63, width: 64"]long1[/TD]
[TD="class: xl63, width: 64"]lat2[/TD]
[TD="class: xl63, width: 64"]long2[/TD]

[TD="class: xl64"]54.99894[/TD]
[TD="class: xl64"]-1.49062[/TD]
[TD="class: xl64"]55.00885[/TD]
[TD="class: xl64"]-1.5185
[/TD]

</tbody>

=ACOS(COS(RADIANS(90-A2)) *COS(RADIANS(90-C2)) +SIN(RADIANS(90-A2)) *SIN(RADIANS(90-C2)) *COS(RADIANS(B2-D2)))





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






 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
I don't know what you are doing but when I copy your data,
and then paste your formula in a cell I get the value
[TABLE="width: 64"]
<colgroup><col width="64"></colgroup><tbody>[TR]
[TD="width: 64, align: right"]0.423551
[/TD]
[/TR]
</tbody>[/TABLE]


Is that the value which you expect?
 
Upvote 0
Hm. I just repeated that and got a different result, 0.000328. I didn't save my first attempt at this so I can't be sure if I entered the correct values at that time.
 
Upvote 0
It doesn't post anything in the cell at all, not even an error.

Hi, welcome to the board - a few things that you could check that might help:

1. Check that you can see the formula in the formula bar.
2. Check that the font colour is not set to either white or the same as the background colour of the cell.
3. Check that the number format of the cell is not hiding the result (temporarily change to general to see if it resolves the problem)
4. Check that there is no conditional formatting that might be hiding the result (temporarily remove any CF to see if it resolves the problem)
 
Upvote 0
I found an implementation of haversine which is slightly different. I also included your original formula (although I changed the layout a bit). Both give the same result for your data but I think you need to multiple by the radius of the earth (in km or miles) to get the actual distance.


Book1
ABCDE
1LatitudeLongitudeLatitude RadiansLongitude Radians
2Point 154.99894-1.490620.959912588-0.026016227
3Point 255.00885-1.51850.96008555-0.026502825
4Difference0.000172962-0.000486598
5a, c2.69495E-080.000328326
6Radius (km, miles)63713959
7Distance (km, miles)2.0917668171.299843796
8Original calculation0.000328326
9Ditance (km, miles)2.0917668171.299843797
Sheet1
Cell Formulas
RangeFormula
D2=RADIANS(B2)
D3=RADIANS(B3)
D4=D3-D2
D5=SIN(D4/2)^2+COS(D2)*COS(D3)*SIN(E4/2)^2
D7=D6*E5
D9=D6*E8
E2=RADIANS(C2)
E3=RADIANS(C3)
E4=E3-E2
E5=2*ATAN2(SQRT(1-D5),SQRT(D5))
E7=E6*E5
E8=ACOS(COS(RADIANS(90-B2)) *COS(RADIANS(90-B3)) +SIN(RADIANS(90-B2)) *SIN(RADIANS(90-B3)) *COS(RADIANS(C2-C3)))
E9=E6*E8


WBD
 
Upvote 0
All sorted now thank you.
It was a schoolboy error on my behalf.
I had downloaded a spreadsheet from the net and hadn't realised the column I was using had a 'style' applied to it meaning it wasn't been shown (but not a white font on white background which I had checked)
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,191
Members
453,021
Latest member
pingpong7117

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