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
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
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I've never used arrays in that manner & therefore not sure if it's possible or not.
 
Upvote 0

Forum statistics

Threads
1,215,424
Messages
6,124,817
Members
449,190
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top