ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA code question (https://www.excelbanter.com/excel-discussion-misc-queries/132913-vba-code-question.html)

JEV

VBA code question
 
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.

Gary''s Student

VBA code question
 
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

--
Gary''s Student
gsnu200708


"JEV" wrote:

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.


Bob Phillips

VBA code question
 

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)



"JEV" wrote in message
...
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.





All times are GMT +1. The time now is 12:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com