#1   Report Post  
Posted to microsoft.public.excel.misc
JEV JEV is offline
external usenet poster
 
Posts: 9
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default 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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code question for clearing a command checkbox. Newbeetle Excel Discussion (Misc queries) 4 February 13th 07 09:05 AM
a tough question - calculating a number out of an alphanumeric code usingexcel Excel Discussion (Misc queries) 2 August 3rd 06 06:07 PM
question about excessive code in replacing #N/A when using VLOOKUP njuneardave Excel Discussion (Misc queries) 4 June 21st 06 03:14 AM
Easy VB code question Anthony Excel Discussion (Misc queries) 2 July 8th 05 08:45 PM
syntax question - cell references in VB code needyourhelp New Users to Excel 1 March 2nd 05 08:52 PM


All times are GMT +1. The time now is 10:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"