bonjour,
une proposition via une macro
Sub aargh()
Set wsAB = Worksheets.Add
wsAB.Name = "f1f2"
With wsAB
.Cells(1, 1) = "Pivot"
.Cells(1, 2) = "Tot A f1"
.Cells(1, 3) = "Tot B f1"
.Cells(1, 4) = "Tot A f2"
.Cells(1, 5) = "Tot B f2"
End With
Set wsA = Worksheets.Add
wsA.Name = "f1"
With wsA
.Cells(1, 1) = "Pivot"
.Cells(1, 2) = "Tot A f1"
.Cells(1, 3) = "Tot B f1"
End With
Set wsB = Worksheets.Add
wsB.Name = "f2"
With wsB
.Cells(1, 1) = "Pivot"
.Cells(1, 2) = "Tot A f2"
.Cells(1, 3) = "Tot B f2"
End With
Set ws1 = Sheets("Feuil1")
Set ws2 = Sheets("Feuil2")
i1 = 2
i2 = 2
iAB = 1
iA = 1
iB = 1
Do Until k1 = "zz" And k2 = "zz"
If k1 <> "zz" Then k1 = ws1.Cells(i1, 2)
If k2 <> "zz" Then k2 = ws2.Cells(i2, 2)
If k1 = k2 Then
iAB = iAB + 1
wsAB.Cells(iAB, 1) = k1
wsAB.Cells(iAB, 2) = ws1.Cells(i1, "J")
wsAB.Cells(iAB, 3) = ws1.Cells(i1, "K")
wsAB.Cells(iAB, 4) = ws2.Cells(i2, "I")
wsAB.Cells(iAB, 5) = ws2.Cells(i2, "J")
i1 = i1 + 1
i2 = i2 + 1
ElseIf k1 < k2 Then
iA = iA + 1
wsA.Cells(iA, 1) = k1
wsA.Cells(iA, 2) = ws1.Cells(i1, "J")
wsA.Cells(iA, 3) = ws1.Cells(i1, "K")
i1 = i1 + 1
Else
iB = iB + 1
wsB.Cells(iB, 1) = k2
wsB.Cells(iB, 2) = ws2.Cells(i2, "I")
wsB.Cells(iB, 3) = ws2.Cells(i2, "J")
i2 = i2 + 1
End If
If ws1.Cells(i1, 2) = "" Then k1 = "zz"
If ws2.Cells(i2, 2) = "" Then k2 = "zz"
DoEvents
Loop
MsgBox "fin"
End Sub