Werte importieren
10.07.2003 07:59:35
Sneaker
wie schaffe ich es bei dem unterem Makro, dass alle Zeilen zwischen einem Anfangs und einem Endpunkt im meine Tabelle importiert werden und nicht nur die Zeile mit dem Suchbegriff?
Tausen Dank
Sneaker
Sub GrepText()
Dim fs As FileSearch
Dim lRow As Long, lFile As Long
Dim iCounter As Integer
Dim sDir As String, sTxt As String, sBegriff As String
Application.ScreenUpdating = False
sDir = Range("H1").Value
sBegriff = Range("H3").Value
Columns("A").ClearContents
Set fs = Application.FileSearch
With fs
.LookIn = sDir
.Filename = Range("H2").Value
.Execute
For iCounter = 1 To .FoundFiles.Count
lFile = lFile + 1
If lFile Mod 100 = 0 Then Application.StatusBar = "Bearbeite Datei " & lFile & "..."
Open .FoundFiles(iCounter) For Input As #1
Do Until EOF(1)
Line Input #1, sTxt
If InStr(sTxt, sBegriff) Then
lRow = lRow + 1
Cells(lRow, 1).Value = sTxt
End If
Loop
Close
Next iCounter
End With
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub