Yes, it is crazy but what can you do. Thank you so much for the link that
will come in handy.
Do you have any ideas why this code is not working? I'm just learning. Per
Jessen stated I needed a next statement to continue the loop. So right if I
take that line out it will copy the first row it finds. I need it to copy
all of the rows that has that value. Any ideas?
Daisy :)
"Rick Rothstein" wrote:
Your company has the help files locked out? That seems to me like a crazy
thing for them to have done. Here is a link to the online help files...
http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
Not as convenient as being able to hit F1, but it should be of some help to
you.
--
Rick (MVP - Excel)
"daisy2008" wrote in message
...
I have played with this code but I can not make it work. Can someone
please
help me fix this? My company has the help files locked out. comes back
as
Compile error: For without Next.
Sub copy_rows()
Dim lastrow As Long, i As Long
Dim wksToSearch As Worksheet
Dim rngToSearch As Range
Dim rngFound As Range
lastrow = Sheets("Sheet1").Cells(Rows.Count, 3).End(xlUp).Row
For i = lastrow To 1 Step -1
Set wksToSearch = Sheets("Sheet1")
Set rngToSearch = wksToSearch.Columns("C")
Set rngFound = rngToSearch.Find(What:=ActiveCell, LookIn:=xlValue)
If rngFound Is Nothing Then
MsgBox "No data found"
Else
wksToSearch.Select
rngFound.EntireRow.Copy Sheets("Sheet2").Range("A3")
End If
End Sub