Sub Text_Import_alle()
Dim i As Integer
Dim Zeile As Integer
Dim startflag As Boolean
Dim endeflag As Boolean
Dim pfadfile As String
Dim fileart As String
'StartVerzeichnis - bitte anpassen
ChDrive "c:\"
ChDir "\temp"
pfadfile = "c:\temp\"
fileart = "*.txt"
'Start der Verarbeitung
Zeile = 2
fn = Dir(pfadfile & fileart)
Do While fn <> ""
Open fn For Input As #1
'Cells(Zeile, 1).Value = fn ' Dateiname
spalte = 1
Do While Not EOF(1)
spalte = 1
Line Input #1, strTxt
'richtige spalte bestimmen
skey = False
lSpalte = Cells(1, 256).End(xlToLeft).Column
For x = 1 To lSpalte
If Cells(1, x).Value = Left(strTxt, 3) Then
spalte = x
skey = True
Exit For
End If
Next x
If Not skey Then
Cells(1, lSpalte + 1).Value = Left(strTxt, 3)
spalte = lSpalte + 1
End If
Cells(Zeile, spalte).Value = Mid(strTxt, 4)
' Zeile = Zeile + 1
Loop
Close
Zeile = Zeile + 1
fn = Dir()
Loop
End Sub
GrussSub TextImport()
Dim lngZeile As Long
Dim vntSpalte
Dim strText As String
Dim strFile As String
'anpassen
Const strPfad As String = "c:\test\test\"
Const strArt As String = "*.txt"
Application.ScreenUpdating = False
lngZeile = 2
strFile = Dir(strPfad & strArt)
Do While strFile <> ""
Open strPfad & strFile For Input As #1
Do While Not EOF(1)
Line Input #1, strText
vntSpalte = Application.Match(--Left(strText, 3), Rows(1), 0)
If IsError(vntSpalte) Then
vntSpalte = _
Cells(1, Columns.Count).End(xlToLeft).Column - (Application.CountA(Rows(1)) <> 0)
Cells(1, vntSpalte) = --Left(strText, 3)
End If
Cells(lngZeile, vntSpalte).Value = Mid(strText, 4)
Loop
Close #1
lngZeile = lngZeile + 1
strFile = Dir()
Loop
'nach Überschrift sortieren
Range("A1").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
Application.ScreenUpdating = True
End Sub
Sub TextImport()
Dim lngZeile As Long
Dim vntSpalte
Dim strText As String
Dim strFile As String
Dim arrText, strTmp
'anpassen
Const strPfad As String = "c:\test\test\"
Const strArt As String = "*.txt"
Application.ScreenUpdating = False
lngZeile = 2
strFile = Dir(strPfad & strArt)
Do While strFile <> ""
Open strPfad & strFile For Input As #1
Do While Not EOF(1)
Line Input #1, strText
arrText = Split(strText, vbLf)
For Each strTmp In arrText
If strTmp <> "" Then
vntSpalte = Application.Match(--Left(strTmp, 3), Rows(1), 0)
If IsError(vntSpalte) Then
vntSpalte = _
Cells(1, Columns.Count).End(xlToLeft).Column - _
(Application.CountA(Rows(1)) <> 0)
Cells(1, vntSpalte) = --Left(strTmp, 3)
End If
Cells(lngZeile, vntSpalte).Value = Mid(strTmp, 4)
End If
Next
Loop
Close #1
lngZeile = lngZeile + 1
strFile = Dir()
Loop
'nach Überschrift sortieren
Range("A1").Sort Key1:=Range("A1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight
Application.ScreenUpdating = True
End Sub