[VBA-E] Problème de tableau
Bonjour,
Je souhaite remplir un tableau à deux dimensions à partir des données d'un fichier CSV. Mais j'ai des problème avec le ReDim. Je reçois le message :
Citation:
Erreur d'exécution '9'. L'indice n'appartient pas à la sélection.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Public Sub extractFile(strPath)
Dim sSep As String
sSep = ";"
Dim strNextLine As String
Dim asTemp() As String
Dim asData()
Dim i, j As Integer
Open strPath For Input As #1
i = 0
While EOF(1) = False
Line Input #1, strNextLine
asTemp = Split(strNextLine, sSep)
MsgBox ("ReDim asData(" & i & ", " & UBound(asTemp) & ")")
ReDim Preserve asData(i, UBound(asTemp))
For j = 0 To UBound(asTemp)
asData(i, j) = asTemp(j)
Next
i = i + 1
Wend
Close #1 |
End Sub