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 test()
with ThisWorkbook.Worksheets(1)
tab1 = .Range("A1").CurrentRegion
tab2= .Range("A16").CurrentRegion
If UBound(tab2) = UBound(tab1) Then
MyCol = Application.Index(tab1, , 2)
end with
with ThisWorkbook.Worksheets(2)
'on a un tableau de depart
.Range("A1").Resize(UBound(tab2), UBound(tab2, 2)).Value = tab2
'on a un tableau final
Call FusionTableau(tab2, MyCol)
.Range("A16").Resize(UBound(tab2), UBound(tab2, 2)) = tab2
End If
End Sub
'Fusion tableau/ajout lignes
Sub FusionTableau(ByRef TableauSource As Variant, Ligne As Variant)
'definition variables
Dim i As Long, j As Long
'forcage
ReDim Preserve TableauSource(1 To UBound(TableauSource, 1), 1 To UBound(TableauSource, 2) + 1)
'Fusion
For i = 1 To UBound(Ligne, 1)
TableauSource(i, UBound(TableauSource, 2)) = Ligne(i, 1)
Next i
'ici ce qui servirait pour une fonction byval
'Assignation
'FusionTableau = TableauSource
End Sub |
Partager