I have a list of locations with corresponding lat/long coordinates and am trying to calculate initial bearings between two locations. The formula I am using is:
=IF(ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2)<0,ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2)*-1,ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2))
Column I = Latitude 1, Column H = Longitude 1, Column K = Latitude 2, Column J = Longitude 2
It seems to work in some instances and in other cases does not. For example, when using these coordinates: Lat/Long1 = -86.879036, 33.525203 and Lat/Long2 = -86.1852, 39.70122 it seems the bearing (4.95, N) is correct. However, when using: Lat/Long1 = -86.879036, 33.525203 and Lat/Long2 = -89.864998, 35.01351 the bearing (58.07, ENE) is incorrect.
Any ideas as to why this formula seems to work sometimes and at other times not?
=IF(ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2)<0,ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2)*-1,ROUND(DEGREES(ATAN2(COS(RADIANS($I2))*SIN(RADIANS($K2))-SIN(RADIANS($I2))*COS(RADIANS($K2))*IF($J2=$H2,$H2,COS(RADIANS($J2-$H2))),IF($J2=$H2,$H2,SIN(RADIANS($J2-$H2)))*COS(RADIANS($K2)))),2))
Column I = Latitude 1, Column H = Longitude 1, Column K = Latitude 2, Column J = Longitude 2
It seems to work in some instances and in other cases does not. For example, when using these coordinates: Lat/Long1 = -86.879036, 33.525203 and Lat/Long2 = -86.1852, 39.70122 it seems the bearing (4.95, N) is correct. However, when using: Lat/Long1 = -86.879036, 33.525203 and Lat/Long2 = -89.864998, 35.01351 the bearing (58.07, ENE) is incorrect.

Any ideas as to why this formula seems to work sometimes and at other times not?