1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Sub test()
Dim dl1 As Integer, dl2 As Integer, cel1 As Range, cel2 As Range, dj As Integer
Dim wsf1 As Range, wsf2 As Range
With Workbooks("essai1.xlsm").Sheets("feuil1")
dl1 = .Range("a" & .Rows.Count).End(xlUp).Row
Set wsf1 = .Range("a2:a" & dl1)
End With
With Workbooks("essai2.xlsm").Sheets("feuil1")
dl2 = .Range("k" & .Rows.Count).End(xlUp).Row
Set wsf2 = .Range("k2:k" & dl2)
End With
dj = 2
For Each cel1 In wsf1
For Each cel2 In wsf2
If cel2 = cel1 Then
Workbooks("essai1.xlsm").Sheets("feuil1").Range("j" & dj) = cel2
dj = dj + 1
End If
Next cel2
Next cel1
End Sub |
Partager