ich wollte Euch einen neuen Lösungsansatz zum CSV Import geben, da alle die ich finden konnte, sich als nicht ausreichend herausgestellt haben.
Damit es funktioniert müsst Ihr im Codefenster auf Verweise>Microsoft Scripting Runtime aktivieren.
Code:
======================================================
Function funcImportTextFile(strFullPath As String, deLimiter As String) As Boolean
On Error GoTo ErrHandler
Dim ar() As String
Dim fso As FileSystemObject
Dim ts As TextStream
Dim strActLine As String
Dim i&
Dim iRow&
Set fso = New FileSystemObject
Set ts = fso.OpenTextFile(strFullPath, ForReading)
Workbooks.Add 'Wird in eine neue Mappe importiert, kann geändert werden
'Erste Reihe
iRow = 1
'einlesen
Do Until ts.AtEndOfStream
strActLine = ts.ReadLine
ar() = Split(strActLine, deLimiter)
For i = 0 To UBound(ar) Step 1
If IsNumeric(ar(i)) Then
Cells(iRow, i + 1) = CDbl(ar(i))
ElseIf IsDate(ar(i)) Then
Cells(iRow, i + 1) = CDate(ar(i))
ElseIf IsError(ar(i)) Then
Cells(iRow, i + 1) = "ERROR"
Else
Cells(iRow, i + 1) = ar(i)
End If
Next i
iRow = iRow + 1
Loop
funcImportTextFile = True
Exit Function
ErrHandler:
MsgBox "Fehler in funcImportTextFile"
End Function
=========================================
Ende
Viele Grüße
Florian