Sub Calcul()
Dim dur#, RT#, dmax&, t, ub&, resu$(), f$, i&, sinLat#, cosLat#, j&, da#, n&
dur = Timer
RT = 6378.137 'rayon terrestre en km
dmax = Int(Val(Feuil1.[P1])) 'distance maximum retenue en km, cellule à adapter éventuellement
t = Feuil1.[A2:C35586] 'plage à adapter éventuellement
ub = UBound(t)
ReDim resu(1 To ub, 1 To 1)
f = String(Len(CStr(dmax)), "0") & ".0 k\m " 'format des distances
For i = 1 To ub - 1
sinLat = Sin(t(i, 2)): cosLat = Cos(t(i, 2))
For j = i + 1 To ub
da = sinLat * Sin(t(j, 2)) + cosLat * Cos(t(j, 2)) * Cos(t(i, 3) - t(j, 3)) 'cosinus de la distance angulaire
da = Atn(Sqr(1 - da ^ 2) / da) 'distance angulaire en radian
If da * RT < dmax Then resu(i, 1) = resu(i, 1) & Format(da * RT, f) & t(j, 1) & "#": n = n + 1
Next j, i
Call RAZ
Feuil2.[B2].Resize(ub) = resu 'restitution
Feuil2.Activate
dur = (Timer - dur) / 86400
MsgBox "Nombre de distances retenues " & Format(n, "#,##0") & vbLf & "Durée du calcul " & Minute(dur) & " min " & Second(dur) & " s"
End Sub