VBA code question

J

JEV

I'm new to VBA and have been using macros by recording them. I don't know how
to approach this...

What would code look like if it needed to:
Proceed down a column until it hits a cell with the second instance of the
word "QUALITY".
Then that entire row is copied to the preceeding worksheet, and then returns
to the same cell it found the second word "QUALITY" in.

Thanks for your insights.
 
G

Gary''s Student

If the data is on Sheet2 and the preceeding sheet is Sheet1:


Sub JEV()
k = 0
Set r = Range("A:A")
For Each rr In r
If rr.Value = "QUALITY" Then
k = k + 1
If k = 2 Then
Set rf = rr.EntireRow
Set rt = Sheets("Sheet1").Range("A1")
rf.Copy rt
rr.Select
Exit Sub
End If
End If
Next
End Sub
 
B

Bob Phillips

For Each cell In Columns(1)
If cell.Value = "QUALITY" then
If fOneFound Then
cell.Copy Worksheets("Sheet1").Range("A1")
Exit For
Else
fOneFound = TRUE
End If
End If
Next cell

is one way


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
Top