Option
Explicit
Sub
ImportA()
Dim
sLineBuffer
As
Variant
, sColumnsBuffer
As
Variant
Dim
x
As
Long
, y
As
Long
Dim
sArr2D()
Dim
rng
As
Range
Dim
sDateiname
As
String
sDateiname =
"C:\Test\Test.txt"
sLineBuffer = Split(getFile(sDateiname), Chr(10))
sColumnsBuffer = Split(sLineBuffer(0),
";"
)
ReDim
sArr2D(1
To
UBound(sLineBuffer), 1
To
UBound(sColumnsBuffer) + 1)
For
x = LBound(sLineBuffer)
To
UBound(sLineBuffer)
Step
1
sColumnsBuffer = Split(sLineBuffer(x),
";"
)
For
y = LBound(sColumnsBuffer)
To
UBound(sColumnsBuffer)
Step
1
sArr2D(x + 1, y + 1) = sColumnsBuffer(y)
Next
y
Next
x
ActiveSheet.Range(
"A1"
).Resize(UBound(sArr2D, 1), UBound(sArr2D, 2)) = sArr2D
End
Sub
Function
getFile(sFile
As
String
)
As
String
Dim
ff
As
Integer
: ff = FreeFile
Open sFile
For
Binary
As
#ff
getFile = Space$(LOF(ff))
Get
#ff, , getFile
Close #ff
End
Function