Ich habe den folgenden Code für die Suche ein bestimmtes wort New york in Modulen. der code gibt aus, wie oft sich das Wort in Modulen befindet und in welchen Modulen. Ich will jetzt das der Code auch noch Washington in Modulen sucht und gibt aus wie oft das Wort in Modulen kam und in welchen Modulen.
Code:
Sub CheckSpacesInModules()
On Error GoTo Err_CheckSpacesInModules
Dim lngCounterA As Long, lngCounterB As Long
Dim modModule As Module
Dim zahl ' das ist Dein Zähler
For lngCounterA = 0 To Modules.Count - 1
Set modModule = Modules.Item(lngCounterA)
zahl=0
With modModule
For lngCounterB = 1 To .CountOfLines
If Trim(.Lines(lngCounterB, 1)) = "New york" Then
.ReplaceLine lngCounterB, ""
zahl=zahl+1
End If
Next lngCounterB
End With
Msgbox "New York kam im Modul " & modModule & " " & zahl & " mal vor."
Next lngCounterA
Exit_CheckSpacesInModules:
Exit Sub
Err_CheckSpacesInModules:
MsgBox Err.Description, vbExclamation, "Error #" & Err.Number
Resume Exit_CheckSpacesInModules
End Sub