Function matran(x)
'
' matran Macro
'
Const PI As Double = 3.141592654
Dim result As String
rownum = ActiveCell.Row
colnum = ActiveCell.Column
Set ToaDo = Sheets("ToaDo")
Set Matrix = Sheets("Matrix")
lat1 = Application.WorksheetFunction.VLookup(Matrix.Cells(rownum, 1), ToaDo.Range("A1:N200"), 13, 0) * PI / 180
lat2 = Application.WorksheetFunction.VLookup(Matrix.Cells(2, colnum).Value, ToaDo.Range("A1:N200"), 13, 0) * PI / 180
lon1 = Application.WorksheetFunction.VLookup(Matrix.Cells(rownum, 1).Value, ToaDo.Range("A1:N200"), 14, 0) * PI / 180
lon2 = Application.WorksheetFunction.VLookup(Matrix.Cells(2, colnum).Value, ToaDo.Range("A1:N200"), 14, 0) * PI / 180
matran(x) = Application.WorksheetFunction.Acos(Sin(lat1) * Sin(lat2) + Cos(lat1) * Cos(lat2) * Cos(lon2 - lon1)) * 6371
End Function