1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
Sub testB()
Dim wsh1 As Worksheet, wsh2 As Worksheet
Dim plage1 As Range, plageA As Range, plageB As Range
Dim F As Range, A As Range, B As Range
Set wsh1 = Worksheets("Feuilcopiee")
Set wsh2 = Worksheets("Feuilreçu")
Set plage1 = wsh1.Range("A5:A" & wsh1.Cells(Rows.Count, "A").End(xlUp).Row)
Set plageA = wsh2.Range("A5:A" & wsh2.Cells(Rows.Count, "A").End(xlUp).Row)
Set plageB = wsh2.Range(wsh2.Cells(4, 4), wsh2.Cells(4, wsh2.Cells(4, Columns.Count).End(xlToLeft).Column))
wsh2.Range("D5:" & wsh2.Range("D5").Offset(plageA.Rows.Count, plageB.Columns.Count - 1).Address) = 0
For Each F In plage1
Set A = plageA.Find(wsh1.Range(F.Address).Offset(0, 3).Value, LookIn:=xlValues, lookat:=xlWhole)
Set B = plageB.Find(wsh1.Range(F.Address).Offset(0, 1).Value, LookIn:=xlValues, lookat:=xlWhole)
If Not A Is Nothing And Not B Is Nothing Then wsh2.Cells(A.Row, B.Column) = 1
Next
Set wsh1 = Nothing: Set wsh2 = Nothing
Set plage1 = Nothing: Set plageA = Nothing: Set plageB = Nothing
Set A = Nothing: Set B = Nothing
End Sub |
Partager