View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Mick Mick is offline
external usenet poster
 
Posts: 35
Default Find and highlight results macro


The code you guys gave me does everything I want... almost. :)

You guys are great, and I really appreciate your help, but I have a couple
more questions...

1. Would it be possible to...
a. Have it use the currently selected fill color for the highlighting?
b. Prompt for a color to use for the highlighting?

2. Can I make it search the entire worksheet, without a hard-coded Range?

Sub FindAndColour()

Dim c as range
Dim Findstr As String

Findstr = InputBox("Enter search string") ' Enter your search string

With Worksheets(1).Range("a1:D500") ' Change to reflect your search range
Set c = .Find(Findstr, LookIn:=xlValues,Lookat:=XlWhole)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.EntireRow.Interior.ColorIndex = 4 ' Set row to green
Set c = .FindNext(c) ' Look for next occurence of search string
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With

End Sub



"Mick" wrote:

Is it possible to program Excel's Find dialog so that it will search for all
occurrences of a given string and highlight the rows containing the search
string?

What I need is a macro (or something) that will prompt me for a string to
look for, then go through every cell and highlight the rows that contain the
string I specified.

Does anyone have a macro for this?

If not, can someone please help me create a macro that will do this?