Help with find macro


Posted by Ken on December 20, 2001 9:40 AM

Hi

I have several column and rows of data that I need to search through. A loop would be very slow since there are 21 columns and 3000 rows. What I would like to do is say find (this) if you find it then put the date from "A" & the row where you found the data, Then find the next value, then the next, until there are no more occurances. Can anyone help.

Thanks



Posted by Mark O'Brien on December 20, 2001 10:00 AM

This should work, I've used "this" as the text to be found, change it to whatever you want:

Public Sub FindAndReplace()

Dim c As Range
Dim Strng As String

Strng = "this"

With ActiveSheet.UsedRange
Set c = .Find("this", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = Cells(c.Row, 1).Value
Set c = .FindNext(c)
Loop While Not c Is Nothing
End If
End With

End Sub