Makro aus Excel-FAQ funktioniert bei mir nicht
02.12.2003 21:21:03
Josef
Ich habe folgendes Makro in der Excel-FAQ gefunden.Was müßte ich hier beachten, damit es richtig funktionert?
Eine Textdatei erstellte ich bereits,welche im gleichen Ordner wie die Exceldatei mit dem Makro vorhanden ist.
Ich komme leider nicht darauf,was ich falsch mache.
Danke
Josef
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