AW: Einzelne Wörter in Zelle markieren
14.12.2020 15:54:52
Nepumuk
Hallo,
dann so:
Option Explicit
Public Sub SetFontColorKeywordcells()
Dim objRegEx As Object, objMatch As Object
Dim objValueCell As Range, objKeywordCell As Range
Dim lngIndex As Long
With Range(Cells(2, 11), Cells(Rows.Count, 11).End(xlUp)).Font
.Bold = False
.Color = vbBlack
End With
Set objRegEx = CreateObject("VBScript.RegExp")
With objRegEx
.Global = True
.IgnoreCase = True
For Each objKeywordCell In Range(Cells(2, 13), Cells(2, Columns.Count).End(xlToLeft))
.Pattern = objKeywordCell.Text
For Each objValueCell In Range(Cells(2, 11), Cells(Rows.Count, 11).End(xlUp))
Set objMatch = .Execute(objValueCell.Text)
For lngIndex = 0 To objMatch.Count - 1
With objValueCell.Characters(objMatch.Item(lngIndex).FirstIndex + 1, _
objMatch.Item(lngIndex).Length).Font
.Bold = True
.Color = vbRed
End With
Next
Next
Next
End With
Set objMatch = Nothing
Set objRegEx = Nothing
End Sub
Eine Erweiterung der Keyword-Liste wird automatisch verarbeitet wenn du das Makro aufrufst.
Gruß
Nepumuk