gauthamreddy
New Member
- Joined
- Jan 5, 2018
- Messages
- 16
Hi, I have this code that finds the specific work from the column selected in the listbox. The problem I am facing is it only highlights if the cell has that word only once. If the cell has the same word multiple times it is not highlighting those.
Here is the code
Your help is appreciated.
Thanks
Gautham
Here is the code
Code:
Dim rng As Range
Dim i As Long
Dim oldrngrow As Long
Dim myValue As Variant
For i = 0 To Me.ListBox4.ListCount - 1
myValue = Me.ListBox4.List(i)
If myValue = vbNullString Then
End
End If
Set rng = Cells.Find(What:=myValue, After:=Cells(2, ListBox3.ListIndex + 1), LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, MatchCase:=False, SearchFormat:=False)
If rng Is Nothing Then
GoTo skip
End If
oldrngrow = rng.Row
Do While rng.Column = ListBox3.ListIndex + 1
rng.Characters(InStr(rng, myValue), Len(myValue)).Font.ColorIndex = 4
rng.Characters(InStr(rng, myValue), Len(myValue)).Font.Bold = True
rng.Characters(InStr(rng, myValue), Len(myValue)).Font.Size = 14
Set rng = Cells.FindNext(After:=rng)
If oldrngrow = rng.Row Then
Exit Do
End If
Loop
Next i
Your help is appreciated.
Thanks
Gautham