Klar...
18.10.2017 17:58:52
Michael
Ralf,
...das versuche ich sogar oft so zu halten, aber manchmal vergesse ich es.
Hier die Nachreichung: Das ist der Code, den Dieter zuvor in der Mappe hatte, nur ergänzt durch den Colorpicker-Dialog (in fettem Schriftschnitt):
'http://www.ms-office-forum.net/forum/showthread.php?t=187426, von Citizen X, 20.11.2011, 15:02
'Suchwort im Spaltenbereich färben
Sub Suchwortfärben()
Dim strText As String, intFound As Integer
Dim Zelle As Range
Dim Regex As Object, iItems, myItems
Dim lcolor As Long
'mx
If MsgBox("Im Spaltenbereich wird" & vbCrLf & "Wort/Zahl gefärbt nach folgender" & _
" Farbauswahl.", vbInformation + vbYesNo) = vbNo Then Exit Sub
strText = InputBox("Bitte Suchbegriff eingeben", "Suchbegriff")
If Trim(strText) = vbNullString Then Exit Sub
If Application.Dialogs(xlDialogEditColor).Show(10, 0, 125, 125) = True Then
lcolor = ActiveWorkbook.Colors(10)
Else
MsgBox "Farbauswahl abgebrochen!", , "Abbruch"
Exit Sub
End If
Set Regex = CreateObject("Vbscript.Regexp")
With Regex
.Global = True
.IgnoreCase = True
.Pattern = strText
On Error GoTo ErrExit
For Each Zelle In Columns(Selection.Column).SpecialCells(xlCellTypeConstants)
Set iItems = .Execute(Zelle)
For Each myItems In iItems
With Zelle.Characters(myItems.firstIndex + 1, myItems.Length)
' .Font.Superscript = True 'Mx: Text hochstellen
.Font.Color = lcolor 'Mx: Farbe rot
End With
Next
Next
End With
ErrExit:
Set Regex = Nothing
End Sub
LG
Michael