1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| Sub Dupliquer(Rg As Range, NBR%, Optional FIT As Boolean, Optional DEC% = 1)
Dim Rd As Range
N& = Rg.Columns.Count
L& = N + DEC
For B& = 1 To NBR
Set Rd = Rg.Offset(, B * L)
Rg.Copy Rd
If FIT Then For C& = 1 To N: Rd(1, C).ColumnWidth = Rg(1, C).ColumnWidth: Next
Next
If Rd Is Nothing Then Set Rd = Rg
With Rd.Offset(, N).Resize(, Columns.Count - Rd.Columns(N).Column)
.Clear: .ColumnWidth = .Parent.StandardWidth
End With
Set Rd = Nothing
End Sub
Sub Demo()
With Feuil1
With .[D4]
If IsNumeric(.Value) Then N% = .Value - 1
End With
Application.ScreenUpdating = False
Dupliquer .[B11:D46], N
Dupliquer .[B69:D157], N
Dupliquer .[A163:D167], N, True, 0
End With
Dupliquer Feuil2.Range("B4", Feuil2.Cells(Rows.Count, 4).End(xlUp)), N, True
Dupliquer Feuil4.Range("E4", Feuil4.Cells(Rows.Count, 5).End(xlUp)), N, True, 0
End Sub |