Locate and change font color

M

Mobil Dick

I want to locate a # in a large group of no.s & change their font color

Cell(G2):match same number(E14:N79)change font Pattern (red)
 
J

Jacob Skaria

Hi

Try the below and feedback

--The below macro works on Active workbook Worksheets("Sheet1")..

--Initially it turns the font color of all data in the range
Range("E14:N79") to the default color

--Then search for the entries which match cell G2 and turns the font color
to red..

Sub Macro()
Dim varFound As Variant, varSearch As Variant
Dim strAddress As String

varSearch = Range("G2")
Worksheets("Sheet1").Range("E14:N79").Font.ColorIndex = 0
With Worksheets("Sheet1").Range("E14:N79")
Set varFound = .Find(varSearch, LookIn:=xlValues)
If Not varFound Is Nothing Then
strAddress = varFound.Address
Do
varFound.Font.ColorIndex = 3
Set varFound = .FindNext(varFound)
Loop While Not varFound Is Nothing And _
varFound.Address <> strAddress
End If
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top