1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
   | Sub Correspondances()
Dim LastLig As Long, i As Long, Cpt As Long
Dim c As Range
 
Application.ScreenUpdating = False
'On copie la feuille initiale
Feuil1.Copy After:=Feuil1
With ActiveSheet
    LastLig = .Cells(.Rows.Count, 1).End(xlUp).Row
 
    Application.DisplayAlerts = False
    'on scinde la colonne Identifiant en 25
    .Columns("F:F").Insert
    .Range("E2:E" & LastLig).TextToColumns Destination:=.Range("E2"), DataType:=xlDelimited, Space:=True, FieldInfo:=Array(Array(1, 2), Array(2, 2))
    .Columns("I:J").Insert
    'et la colonne Technologie en 3
    .Range("H2:H" & LastLig).TextToColumns Destination:=.Range("H2"), DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(1, 1))
    .Range("I2:I" & LastLig).TextToColumns Destination:=.Range("I2"), DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(1, 1))
    Application.DisplayAlerts = True
 
    'on concatène en L le suivant,le type et l'id suivant
    'et en M le précédent, le type et l'id précédent
    With .Range("L2:L" & LastLig)
        .Formula = "=J2&I2&F2"
        .Value = .Value
    End With
    With .Range("M2:M" & LastLig)
        .Formula = "=H2&I2&E2"
        .Value = .Value
    End With
 
    'on parcoure les colonnes L et I pour indiquer en N les correspondances
    For i = 2 To LastLig
        Set c = .Range("M2:M" & LastLig).Find(.Range("L" & i), LookAt:=xlWhole)
        If Not c Is Nothing Then
            Cpt = Cpt + 1
            c.Offset(, 1) = Cpt & "A"
            .Range("N" & i) = Cpt & "B"
            Set c = Nothing
        End If
    Next i
End With
End Sub | 
Partager