1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub Demo1()
Dim Rg As Range, Rf As Range
With Feuil1
C = Application.Match(.[D7].Value, Feuil2.[K9].CurrentRegion.Rows(1), 0)
If IsNumeric(C) Then C = C + 9 Else Beep: Exit Sub
Set Rg = Feuil2.[B9].CurrentRegion.Columns(1)
Application.ScreenUpdating = False
For R& = 10 To .[B9].CurrentRegion.Rows.Count + 8
Set Rf = Rg.Find(.Cells(R, 2).Value, , xlValues, xlWhole)
If Rf Is Nothing Then
Set Rf = Feuil2.Cells(Rows.Count, 2).End(xlUp)(2)
Rf.Resize(, 5).Value = Application.Index(.Cells(R, 2).Resize(, 7).Value, , [{1,3,4,5,7}])
End If
Rf(1, C).Value = .Cells(R, 10).Value
Next
End With
Set Rf = Nothing: Set Rg = Nothing
Range(Feuil2.[B10], Feuil2.[B9].End(xlDown)).Offset(, 5).Formula = "=SUM(K10:AF10)"
End Sub |