Hi,
The code below works fine. You will see that it highlights the text Blue and Bold, but is their another line of code I can input which will give the text a background colour highlight as well as the existing Blue and Bold? Not the background fill of the whole cell, just highlighting the specific text (as if you had marked it with a highlighter pen).
Any help much appreciated.
The code below works fine. You will see that it highlights the text Blue and Bold, but is their another line of code I can input which will give the text a background colour highlight as well as the existing Blue and Bold? Not the background fill of the whole cell, just highlighting the specific text (as if you had marked it with a highlighter pen).
Any help much appreciated.
VBA Code:
Application.ScreenUpdating = False
Dim Rng As Range
Dim cFnd As String
Dim xTmp As String
Dim x As Long
Dim m As Long
Dim y As Long
Dim xFNum As Integer
Dim xArrFnd As Variant
Dim xStr As String
cFnd = InputBox("Please enter the text, separate them by comma:")
If Len(cFnd) < 1 Then Exit Sub
xArrFnd = Split(cFnd, ",")
For Each Rng In Selection
With Rng
For xFNum = 0 To UBound(xArrFnd)
xStr = xArrFnd(xFNum)
y = Len(xStr)
m = UBound(Split(Rng.Value, xStr))
If m > 0 Then
xTmp = ""
For x = 0 To m - 1
xTmp = xTmp & Split(Rng.Value, xStr)(x)
.Characters(Start:=Len(xTmp) + 1, Length:=y).Font.ColorIndex = 5
.Characters(Start:=Len(xTmp) + 1, Length:=y).Font.Bold = True
xTmp = xTmp & xStr
Next
End If
Next xFNum
End With
Next Rng
Application.ScreenUpdating = True