abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,429
- Office Version
- 2019
- 2010
- Platform
- Windows
hi
i try color this word "in " into any cell by blue and bold after search inputbox
this is my code but not works well
output
i try color this word "in " into any cell by blue and bold after search inputbox
this is my code but not works well
output
Code:
Sub highlighttext()
Dim cell As Range
Dim cellRange As Range
Dim textStart As Integer
Dim wordToFind As String
Set cellRange = Selection
Application.ScreenUpdating = False
' Ask the user what word they want to highlight
wordToFind = InputBox(Prompt:="What word would you like to highlight?")
For Each cell In cellRange
textStart = InStr(cell.Value, wordToFind)
cell.Characters(textStart, Len(wordToFind)).Font.Color = RGB(250, 0, 0)
Next cell
Application.ScreenUpdating = True
End Sub