Question simple de concaténation
Bonjour à tous!
Depuis ce matin je galère à trouver mon erreur...et je vois pas. Soyez indulgent alors s'il vous plait :mrgreen:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Function fusion(a, b As Variant) As Variant
Dim c As Variant
Dim d, e, f, g As Integer
ReDim c(UBound(a, 1) + UBound(b, 1), UBound(b, 2))
Dim i, j As Integer
For i = 1 To UBound(a, 1)
For j = 1 To UBound(a, 2)
c(i, j) = a(i, j)
Next j
Next i
For i = 1 To UBound(b, 1)
For j = 1 To UBound(b, 2)
c(i + UBound(a, 1), j) = b(i, j)
Next j
Next i
fusion = c(UBound(a, 1) + UBound(b, 1), UBound(a, 2))
End Function |
Et pour voir si ca marche
Code:
1 2 3 4 5 6 7 8 9 10
| Sub essai()
e = Range("A1", "A8")
d = Range("B1", "B8")
Range("D1", Cells(UBound(e, 1) + UBound(d, 1), 4)) = fusion(e, d)
End Sub |
En gros ca prend 2 matrices et ca les concatène. J'ai mis un espion sur ma variable c et il choppe les bonnes valeur.
Sauf que quand je fait tourner le programme pour voir si ca marche, ca me met toujours le même nombre et ca ne concatene pas les 2 matrice, l'une en dessous de l'autre.
Si une âme charitable pouvait passer par la ^^
Merci!