Hey team! I have the following code:
Sub Bold_and_Red_Text()
'
' Converts all instances of the designated string, in all selected cells to Red & Bolds them.
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
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
cFnd = InputBox("Enter the text string to highlight *NOTE* Input is case sensitive!")
y = Len(cFnd)
For Each Rng In Selection
With Rng
m = UBound(Split(Rng.Value, cFnd))
If m > 0 Then
xTmp = ""
For x = 0 To m - 1
xTmp = xTmp & Split(Rng.Value, cFnd)(x)
.Characters(Start:=Len(xTmp) + 1, Length:=y).Font.ColorIndex = 3
.Characters(Start:=Len(xTmp) + 1, Length:=y).Font.Bold = True
xTmp = xTmp & cFnd
Next
End If
End With
Next Rng
Application.ScreenUpdating = True
End Sub
What would you recommend modifying If I also wanted to be able to search for the word "shall", and it automatically find instances of "shall" & "Shall". It would then convert all of them to "SHALL" in addition to changing the color index / bold?
Sub Bold_and_Red_Text()
'
' Converts all instances of the designated string, in all selected cells to Red & Bolds them.
'
' Keyboard Shortcut: Ctrl+Shift+Q
'
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
cFnd = InputBox("Enter the text string to highlight *NOTE* Input is case sensitive!")
y = Len(cFnd)
For Each Rng In Selection
With Rng
m = UBound(Split(Rng.Value, cFnd))
If m > 0 Then
xTmp = ""
For x = 0 To m - 1
xTmp = xTmp & Split(Rng.Value, cFnd)(x)
.Characters(Start:=Len(xTmp) + 1, Length:=y).Font.ColorIndex = 3
.Characters(Start:=Len(xTmp) + 1, Length:=y).Font.Bold = True
xTmp = xTmp & cFnd
Next
End If
End With
Next Rng
Application.ScreenUpdating = True
End Sub
What would you recommend modifying If I also wanted to be able to search for the word "shall", and it automatically find instances of "shall" & "Shall". It would then convert all of them to "SHALL" in addition to changing the color index / bold?