Référence du développeur Excel Range.CurrentRegion, propriété Cette propriété renvoie un objet Range qui représente la zone en cours. Celle-ci est une plage limitée par toute combinaison de lignes et de colonnes vides.
Private Sub UserForm_Initialize() ListBox1.Clear Call AddToListbox(Range("A1:D10")) Call AddToListbox(Range("A20:D26")) Call AddToListbox(Range("A32:D50")) End Sub Sub AddToListbox(ByRef myRange As Range) Dim oRange As Range For Each oRange In myRange ListBox1.AddItem oRange.Value Next End Sub
' Déclaration des variables pour les boucles Dim i, j, k As Integer ' Déclaration de tableaux Dim Tab3, Tab2, Tab1 As Variant Dim Tabtot As Variant 'Chargement d'une plage de cellules dans chaque tableaux Tab1 = Range("A1:D10").Value Tab2 = Range("A20:D26").Value Tab3 = Range("A32:D50").Value 'Définit le nombre de colonnes (basé sur Tab1) pour la ListBox. UserForm2.ListBox1.ColumnCount = UBound(Tab1, 2) '''''''''''''''''''''''''''''''''''''''''''''' '' Exécution du code '''''''''''''''''''''''''''''''''''''''''''''' ReDim Tabtot(1 To UBound(TabAirbus, 1) + UBound(TabEmbraer, 1), 1 To UBound(TabAirbus, 2)) As Variant For i = 1 To UBound(Tab1, 1) For j = 1 To UBound(Tab1, 2) For k = UBound(Tab1, 1) + 1 To UBound(Tab1, 1) + UBound(Tab3, 1) Tabtot(i, j) = Tab1(i, j) Tabtot(k, j) = Tab3(k - UBound(Tab1, 1), j) Next k Next j Next i UserForm2.ListBox1.List = Tabtot
Dim i, j, k As Integer
Dim Tab3, Tab2, Tab1 As Variant
ça fonctionne quand j'ai pas trop de tableau à lier (jusqu'à 4 sur)
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpeut-tu m'expliquer (plus pour ma culture) pourquoi malgré le fait que i et j ne sont pas réfèrencer comme "interger" la boucle fonctionne quand même ?
Dim toto As Range, titi as variant Set toto = Union(Range("A1:D2"), Range("A7:D8")) With Worksheets.Add .Name = "tata" toto.Copy Destination:=.Range("A1") titi = .UsedRange Application.DisplayAlerts = False .Delete Application.DisplayAlerts = True End With With ListBox1 .ColumnCount = toto.Columns.Count .List = titi End With