Sub trova()

' Routine per ricerca stella su delta coordinate minimi

For rv% = 2 To 524
  dist_min# = 9999999
  ident_star% = 0
  B_mag# = 0
  AR_ident# = 0
  DEC_ident# = 0
  
  For rb% = 2 To 507
  
  d_AR# = (Sheets("V_list").Cells(rv%, 5) - Sheets("B_list").Cells(rb%, 5)) * 15 * 3600
  d_DEC# = (Sheets("V_list").Cells(rv%, 6) - Sheets("B_list").Cells(rb%, 6)) * 3600
  dist# = Sqr(d_AR# ^ 2 + d_DEC# ^ 2)
  
  If dist# < dist_min# Then
    dist_min# = dist#
    ident_star% = Sheets("B_list").Cells(rb%, 3)
    B_mag# = Sheets("B_list").Cells(rb%, 7)
    AR_ident# = Sheets("B_list").Cells(rb%, 5)
    DEC_ident# = Sheets("B_list").Cells(rb%, 6)
  End If
  
  Next rb%
  
  Sheets("V_list").Cells(rv%, 8) = ident_star%
  Sheets("V_list").Cells(rv%, 9) = B_mag#
  Sheets("V_list").Cells(rv%, 10) = AR_ident#
  Sheets("V_list").Cells(rv%, 12) = DEC_ident#
  
  
Next rv%

End Sub