Bonjour,
Je suis débutant et bricole avec ce que je trouve sur ce type de forum.
Là je coince, la définition des plages ne fonctionne pas. Est ce que quelqu'un pourrait me corriger le code?
Merci d'avance
' Fusion
Dim i&, j&, DerL&
Dim Ws1 As Worksheet, Ws2 As Worksheet
Dim PlageWs1 As Range, PlageWs2 As Range
Set Ws1 = Worksheets("Fusion"): Set Ws2 = Worksheets("Salaires au 31 12")
Set PlageWs1 = (Cells(i, 2), Cells(i, 4))
Set PlageWs2 = (Cells(j, 2), Cells(j, 4))
With Ws2
For i = 1 To .Cells(Rows.Count, 1).End(xlUp).Row
DerL = Ws1.Cells(Rows.Count, 1).End(xlUp)(2).Row
If Not IsError(Application.Match(PlageWs1, PlageWs2, 0)) Then
For j = 1 To DerL
If (Cells(j, 2) + Cells(j, 3) + Cells(j, 4)) = (.Cells(i, 2) + .Cells(i, 3) + .Cells(i, 4)) Then
Ws1.Cells(j, 18) = .Cells(i, 13)
Ws1.Cells(j, 19) = .Cells(i, 14)
Ws1.Cells(j, 20) = .Cells(i, 17)
End If
Next
Else
Ws1.Cells(DerL, 1) = .Cells(i, 1)
Ws1.Cells(DerL, 2) = .Cells(i, 2)
Ws1.Cells(DerL, 3) = .Cells(i, 3)
Ws1.Cells(DerL, 4) = .Cells(i, 4)
Ws1.Cells(DerL, 5) = .Cells(i, 5)
Ws1.Cells(DerL, 6) = .Cells(i, 6)
Ws1.Cells(DerL, 7) = .Cells(i, 7)
Ws1.Cells(DerL, 8) = .Cells(i, 8)
Ws1.Cells(DerL, 9) = .Cells(i, 9)
Ws1.Cells(DerL, 10) = .Cells(i, 10)
Ws1.Cells(DerL, 11) = .Cells(i, 11)
Ws1.Cells(DerL, 12) = .Cells(i, 12)
Ws1.Cells(DerL, 15) = .Cells(i, 15)
Ws1.Cells(DerL, 16) = .Cells(i, 16)
Ws1.Cells(DerL, 18) = .Cells(i, 13)
Ws1.Cells(DerL, 19) = .Cells(i, 14)
Ws1.Cells(DerL, 20) = .Cells(i, 17)
DerL = DerL + 1
End If
Next
End With
End Sub