Wenn Spalte voll, dann .....
28.11.2006 09:51:07
Frank
ich habe das folgend Makro im Forum gefunden. Funkktioniert wirklich super bis Spaltenende.
Kann mir jemand das Makro ändern, so das wenn Spalte A voll ist es in Spalte B weiterschreibt und dann in Spalte C u.s.w.
Oder, in eine neues Tabellenblatt in Spalte A u.s.w.
Das Makro hält in dieser Zeile Cells(intRow, intCol) = txt an wenn die Zeile 65536 erreicht wird.
Vielleicht kann mir da jemand helfen.
Besten Dank im Voraus
Gruß Frank
Sub Open_All_Textfiles()
Dim i As Long, TotFiles As Long
Dim intRow As Long, intCol As Integer, txt As String
Dim gefFile As String, dname As String
Dim Suchpfad As String, suchbegriff As String
Dim oldStatus As Variant
Suchpfad = InputBox("Geben Sie den Ordner an, der durchsucht werden soll.", "Pfad definieren", "D:\Schwimmhalle\Journale\") 'Application.DefaultFilePath)
If Suchpfad = "" Then Exit Sub
Dateiform = InputBox("Geben Sie den Dateityp an der gesucht werden soll", "Dateierweiterung", "*.txt")
If Dateiform = "" Then Exit Sub
Application.ScreenUpdating = True
oldStatus = Application.StatusBar
With Application.FileSearch
.LookIn = Suchpfad
.SearchSubFolders = False
.Filename = Dateiform
If .Execute() > 0 Then
TotFiles = .FoundFiles.Count
Application.StatusBar = "Total " & TotFiles & " gefunden"
For i = 1 To .FoundFiles.Count
gefFile = .FoundFiles(i)
'Hier beginnt dein Code
Open gefFile For Input As #1
Do Until EOF(1)
Line Input #1, txt
intRow = intRow + 1
Do Until txt = ""
intCol = intCol + 1
If InStr(txt, "|") Then
Cells(intRow, intCol) = Left(txt, InStr(txt, "|") - 1)
txt = Right(txt, Len(txt) - InStr(txt, "|"))
Else
Cells(intRow, intCol) = txt
txt = ""
End If
Loop
intCol = 0
Loop
Close #1
'Hier endet dein Code
Next i
End If
End With
Application.StatusBar = oldStatus
Application.ScreenUpdating = True
End Sub
Anzeige