Sub
Datei_Importieren()
Dim
strFileName
As
String
, arrDaten, arrTmp, lngR
As
Long
, lngLast
As
Long
, intLastS
As
Long
Const
cstrDelim
As
String
=
";"
Call
Tabelle_Leeren
With
Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect =
False
.Title =
"Datei wählen"
.InitialFileName =
"c:\test\*.csv"
If
.Show = -1
Then
strFileName = .SelectedItems(1)
End
If
End
With
If
strFileName <>
""
Then
Application.ScreenUpdating =
False
Open strFileName
For
Input
As
#1
arrDaten = Split(Input(LOF(1), 1), vbCrLf)
Close #1
For
lngR = 1
To
UBound(arrDaten)
arrTmp = Split(arrDaten(lngR), cstrDelim)
If
UBound(arrTmp) > -1
Then
With
Tabelle4
lngLast = .Cells(Rows.Count, 1).
End
(xlUp).Row + 1
lngLast = Application.Max(lngLast, 1)
.Cells(lngLast, 1).Resize(, UBound(arrTmp) + 1) _
= Application.Transpose(Application.Transpose(arrTmp))
End
With
End
If
Next
lngR
End
If
End
Sub
<strong>Die Zeile: </strong>
lngLast = Application.Max(lngLast, 1)
.Cells(lngLast, 1).Resize(, UBound(arrTmp) + 1)
<strong>habe ich so verändert:<span id=
"cke_bm_129S"
style=
"display: none;"
> </span><span style=
"display: none;"
> </span></strong>
lngLast = Application.Max(lngLast, 1)
.Cells(lngLast, <strong>6</strong>).Resize(, UBound(arrTmp) + 1)<strong><span id=
"cke_bm_129E"
style=
"display: none;"
> </span>
Jedoch wird nur der letzte Datensatz immer ab Spalte F eingefügt, sonst nichts.
Weiß jemand, woran das liegen könnte?
</strong><span style=
"display: none;"
> </span>