Hello,
Any help here would be appreciated please.
The included VBA code almost meets the intended purpose, however, I need a solution that highlights all parameters contained between ##, %% or potentially other special characters (special characters included).
For instance, in the cell range B2:B10 we would find something like:
Thank you
Any help here would be appreciated please.
The included VBA code almost meets the intended purpose, however, I need a solution that highlights all parameters contained between ##, %% or potentially other special characters (special characters included).
For instance, in the cell range B2:B10 we would find something like:
orChecked at ##date1## and ##hour1##
What is between ## and %% can be anything, so while I can easily highlight ## or %% I need to be able to highlight whatever parameter is between like this:Left at %%date1%% and %%hour1%%
Checked at %%date1%% and %%hour1%%
VBA Code:
Sub HighlightStrings()
'Updateby Extendoffice
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 = 3
xTmp = xTmp & xStr
Next
End If
Next xFNum
End With
Next Rng
Application.ScreenUpdating = True
End Sub
Thank you