E
ela
some time ago, I was kindly provided with a primitive codes followed with my
modifications as follows. The function is capable of coloring a text pattern
input by users. I would like to enhance it to a more robust way in:
1) instead of adding escape character for ], ', etc. is there any way to let
the program know I'm specifying symbols for the checklist?
2) instead of requiring users to input the patterns one by one, can I do
anything to let them input the patterns only once? e.g.
something like:
[boy|girl]
so the program colors either boy or girl, rather than letting the user input
"boy" and then "girl"?
==============================
Option Explicit
Sub RedLetter()
Dim s As String * 1
Dim c As Range
Dim i As Long
s = InputBox("Which letter to redden?")
If s Like "[!A-Za-z\[\]]" Then
MsgBox ("Must specify a LETTER")
Exit Sub
End If
For Each c In Selection
With c
If .HasFormula Then .Value = .Text
'.Font.TintAndShade = -0.5
For i = 1 To Len(.Text)
If LCase(Mid(.Text, i, 1)) = LCase(s) Then
.Characters(i, 1).Font.Color = RGB(255, 30, 15)
End If
Next i
End With
Next c
End Sub
modifications as follows. The function is capable of coloring a text pattern
input by users. I would like to enhance it to a more robust way in:
1) instead of adding escape character for ], ', etc. is there any way to let
the program know I'm specifying symbols for the checklist?
2) instead of requiring users to input the patterns one by one, can I do
anything to let them input the patterns only once? e.g.
something like:
[boy|girl]
so the program colors either boy or girl, rather than letting the user input
"boy" and then "girl"?
==============================
Option Explicit
Sub RedLetter()
Dim s As String * 1
Dim c As Range
Dim i As Long
s = InputBox("Which letter to redden?")
If s Like "[!A-Za-z\[\]]" Then
MsgBox ("Must specify a LETTER")
Exit Sub
End If
For Each c In Selection
With c
If .HasFormula Then .Value = .Text
'.Font.TintAndShade = -0.5
For i = 1 To Len(.Text)
If LCase(Mid(.Text, i, 1)) = LCase(s) Then
.Characters(i, 1).Font.Color = RGB(255, 30, 15)
End If
Next i
End With
Next c
End Sub