Option Explicit             'Oblige à déclarer toutes les variables
Sub GenerationResultats()   ' Génère le tableau Resultats
    Const O_NUMERO As Long = 1              'N° colonne NUMERO dans la table O
    Const O_NOM As Long = 2                 '"     "    NOM      "   "   "   "
    Const R_NUMERO As Long = 1
    Const R_NUMERO_POINT As Long = 2
    Const R_NOM As Long = 3
    Const R_NOM_POINT As Long = 4
   
    Dim rOrig As Range                      'Range d'origine
    Dim rResult As Range
    Dim ligO As Long                        'Indice dans lla table O
    Dim ligR As Long                        'Indice dans la table R
    Dim sO_Numero As Variant                'Numéro d'origine
    Dim so_Nom  As String                   'Nom d'origine
    Dim iR_Numero_point As Variant
    Dim sR_Numero_point As String
    Dim sR_Nom_point As String
    Set rOrig = Feuil1.Range(Range("A2"), Range("B2").End(xlDown)) 'Détermination range d'origine
    Set rResult = rOrig.Offset(, 14).Resize(, 4) ' range de résultats
    ligR = 0
    For ligO = 1 To rOrig.Rows.Count       'On balaie le tableau d'origine
        sO_Numero = rOrig(ligO, O_NUMERO).Text           'NUMERO
        so_Nom = rOrig(ligO, O_NOM)                      'Nom
        If (Len(sO_Numero) = 6) Then
            ligR = ligR + 1
            On Error Resume Next
            iR_Numero_point = WorksheetFunction.Match(sO_Numero & ".", rOrig.Columns(O_NUMERO), 0)
            If Err = 1004 Then
                sR_Numero_point = "-"
                sR_Nom_point = "-"
            Else
                sR_Numero_point = rOrig.Cells(iR_Numero_point, O_NUMERO).Text
                sR_Nom_point = rOrig.Cells(iR_Numero_point, O_NOM)
            End If
            On Error GoTo 0
            rResult.Cells(ligR, R_NUMERO) = sO_Numero               ' On positionne les résultats
            rResult.Cells(ligR, R_NOM) = so_Nom
            rResult.Cells(ligR, R_NUMERO_POINT) = sR_Numero_point
            rResult.Cells(ligR, R_NOM_POINT) = sR_Nom_point
        End If
           
    Next ligO
    MsgBox "Fin de traitement"
   
End Sub