Dim tableau tableau = Range("B1:C3")
'contruction du tableau '====================== Dim TabTests() 'Déclaration tableau variable Dim Fin As String 'N° de la dernière ligne du tableau Fin = Sheets("CertJG").Range("BZ65536").End(xlUp).Row If Fin = 1 Then 'un seul test trouvé TabTests = Sheets("CertJG").Range("BZ1").Value 'si un seul test =>Erreur 13 : incompatibilité de type Else 'plusieurs tests trouvés TabTests = Sheets("CertJG").Range("BZ1:BZ" & Fin).Value End If MsgBox TabTests 'si plusieurs tests =>Erreur 13 : incompatibilité de type
Dim tableau tableau = Range("B1:B3") For i = 1 To UBound(tableau) MsgBox tableau(i, 1) Next
End(xlUp).Rowcomme suit :
Dim tableau Dim Lst As String Lst = Range("BZ65536").End(xlUp).Row tableau = Range("BZ1:BZ" & Lst) For i = 1 To UBound(tableau) MsgBox tableau(i, 1) Next
For i = 1 To UBound(tableau)
Dim Lst As String Lst = Range("BZ65536").End(xlUp).Row
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim tableau Dim Lst Lst = Range("BZ65536").End(xlUp).Row tableau = Range("BZ1:BZ" & Lst) If Lst = 1 Then MsgBox Range("BZ1:BZ" & Lst).Value Else For i = 1 To UBound(tableau) MsgBox tableau(i, 1) Next End If
MsgBox tableau(i)n'est donc pas correct quand il n'y a qu'une simple liste (un seule "colonne")?
Option Explicit Option Base 0en tête de module, pour que
MsgBox tableau(i)soit correct?
Private Function faire_tableau(plage As Range) If plage.Cells.Count < 2 Then Dim tabli(1 To 1, 1 To 1) tabli(1, 1) = plage.Value faire_tableau = tabli Erase tabli Else faire_tableau = plage.Value End If End Function
tabl = faire_tableau(Range("A1:A3")) ' la suite n'est là que comme preuve de la bonne exécution For i = 1 To UBound(tabl, 1) For j = 1 To UBound(tabl, 2) MsgBox tabl(i, j) Next Next
tabl = faire_tableau(Range("A1:A3")) ' la suite n'est là que comme preuve de la bonne exécution Ligne = "" For i = 1 To UBound(tabl, 1) For j = 1 To UBound(tabl, 2) If Ligne = "" then Ligne = Ligne & tabl(i, j) Else Ligne = Ligne & chr(13) & tabl(i, j) End if Next j Next i If Ligne <> "" then MsgBox Ligne
For i = 1 To UBound(tabl, 1) For j = 1 To UBound(tabl, 2) MsgBox tabl(i, j) Next Next