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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| 'Redim preserve : Attention on à le droit de redimensionner uniquement la dernière dimension la plus à droite
Sub EditInput()
Application.Calculation = xlManual
Application.ScreenUpdating = False
Dim Index As Long
Dim data() As Variant
Dim i As Long
Dim plage As Range
Dim ReadFile As String
ReadFile = ThisWorkbook.Path & "\Commandes.txt"
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Set fs = CreateObject("Scripting.FileSystemObject")
Set fin = fs.OpenTextFile(ReadFile, ForReading, TristateFalse)
Index = 0
Do While fin.AtEndOfStream <> True
ReadData = fin.readline
Splitdata = Split(ReadData, ";")
ReDim Preserve data(0 To UBound(Splitdata), 0 To Index)
For i = 0 To UBound(Splitdata)
data(i, Index) = Splitdata(i)
Next i
Index = Index + 1
Loop
fin.Close
'data (colonne, lignes)
Worksheets("Feuil1").Range("A1").Resize(UBound(data, 2) + 1, UBound(data, 1) + 1).Value = data
'For i = 0 To UBound(data, 2)
' For j = 0 To UBound(data, 1)
' Set plage = Worksheets("Feuil1").Range(Worksheets("Feuil1").Cells(i + 1, j + 1), Worksheets("Feuil1").Cells(i + 1, j + 1)) = data(j, i)
' Next j
'Next i
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub |
Partager