burniksapwet
Board Regular
- Joined
- Oct 6, 2017
- Messages
- 53
- Office Version
- 2016
Guys I found this code and would like help to update it please. This will currently highlight the words remove, removed, Removed, Remove, Removed: N/A to red in column N. I was hoping it can be updated to where I can look for other words and highlight them a different color rather than create multiple of this code to do those other things. For example I also want to search for the words add, added and have it highlighted in blue. Please help me be added to add as many words as needed to any type of color we need it to be. Thank you in advance.
Sub Macro1()
Dim sPos As Long, sLen As Long
Dim rng As Range
Dim findMe As String
Dim i As Integer
Dim t As Integer
Dim SearchArray
SearchArray = Array("remove", "removed", "Removed", "Remove", "Removed: N/A")
For t = 0 To UBound(SearchArray)
Set rng = Range("N2:N10000")
findMe = SearchArray(t)
For Each rng In rng
With rng
If rng.Value Like "*" & findMe & "*" Then
If Not rng Is Nothing Then
For i = 1 To Len(rng.Value)
sPos = InStr(i, rng.Value, findMe)
sLen = Len(findMe)
If (sPos <> 0) Then
rng.Characters(Start:=sPos, Length:=sLen).Font.Color = RGB(255, 0, 0)
rng.Characters(Start:=sPos, Length:=sLen).Font.Bold = True
i = sPos + Len(findMe) - 1
End If
Next i
End If
End If
End With
Next rng
Sub Macro1()
Dim sPos As Long, sLen As Long
Dim rng As Range
Dim findMe As String
Dim i As Integer
Dim t As Integer
Dim SearchArray
SearchArray = Array("remove", "removed", "Removed", "Remove", "Removed: N/A")
For t = 0 To UBound(SearchArray)
Set rng = Range("N2:N10000")
findMe = SearchArray(t)
For Each rng In rng
With rng
If rng.Value Like "*" & findMe & "*" Then
If Not rng Is Nothing Then
For i = 1 To Len(rng.Value)
sPos = InStr(i, rng.Value, findMe)
sLen = Len(findMe)
If (sPos <> 0) Then
rng.Characters(Start:=sPos, Length:=sLen).Font.Color = RGB(255, 0, 0)
rng.Characters(Start:=sPos, Length:=sLen).Font.Bold = True
i = sPos + Len(findMe) - 1
End If
Next i
End If
End If
End With
Next rng