' Subroutine Latlon berechnet die aufsummierten Kilometer ' 'Input: zweispaltige Daten: Longitude / Latitude 'Output: dreispaltige Daten: Longitude / Latitude / gefahrene Kilometer ' ' Jürgen Heidbeder 8. Juli 2010 Sub latlon() sumkm = 0 Dim i As Double Dim lat1, lon1, lat2, lon2, phi1, phi2, theta1, theta2, d As Double For i = 0 To 4421 lat1 = Cells(1 + i, 2) lat2 = Cells(2 + i, 2) lon1 = Cells(1 + i, 1) lon2 = Cells(2 + i, 1) phi1 = (90 - lat1) * Application.WorksheetFunction.Pi() / 180 phi2 = (90 - lat2) * Application.WorksheetFunction.Pi() / 180 theta1 = lon1 * Application.WorksheetFunction.Pi() / 180 theta2 = lon2 * Application.WorksheetFunction.Pi() / 180 d = 6340# * acos(Sin(phi1) * Sin(phi2) * Cos(theta1 - theta2) + Cos(phi1) * Cos(phi2)) Cells(2 + i, 4) = d sumkm = sumkm + d Cells(2 + i, 3) = sumkm Next i End Sub Public Function acos(x As Double) As Double If Abs(x - 1) < 0.0000000000001 Then acos = 0 Else acos = Application.WorksheetFunction.Pi() / 2 - Atn(x / (Sqr(-x * x + 1))) End Function