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

Thanks Toppers!

I tried your macro, but it didn't seem to do anything until I changed 'Loop
While' as Tom suggested.

I have a couple more question regarding this macro. Please see my next post
if you will.


"Toppers" wrote:

Hi,

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


HTH

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