View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_3_] Bob Phillips[_3_] is offline
external usenet poster
 
Posts: 2,420
Default Copy Non-Consecutive Rows and Paste in a Seperate Worksheet

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim LastRow As Long
Dim NextRow As Long
Dim sh As String

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow

If .Cells(i, "A").Value < sh Then

sh = .Cells(i, "A").Value
On Error Resume Next
If Not Worksheets(sh).Name = sh Then Worksheets.Add.Name =
sh
On Error GoTo 0
If Worksheets(sh).Range("A1").Value = "" Then

NextRow = 1
Else

NextRow = Worksheets(sh).Range("A" &
..Rows.Count).End(xlUp).Row + 1
End If

.Cells(i, "A").Resize(, 2).Copy
Worksheets(sh).Cells(NextRow, "A")
End If
Next i
End With
End Sub

--
__________________________________
HTH

Bob

"elf27" wrote in message
...
I have two worksheets I'm working on.
The first has a long list of items characterized in by one of four
identifiers (Adam, Bob, Charlie, David). So it would be something like
this:

Adam Task 1 Due date X
Bob Task 34 Due date Y
Adam Task 2 Due date Z
Charlie Task 34 Due date Y
David Task 34 Due date Y
...

I want to make it so all of the rows for Adam (an none of the other rows)
are copied and pasted on to a separate worksheet. Then I will do the same
for
Bob, Charlie, and David.

To make it even more complex, I do not want to past the entire contents of
each row, just certain columns. Here, let's say columns 1 and 2. So, the
resulting page for Adam would look like:
Adam Task 1
Adam Task 2

I've been wrestling with this for hours and can't get anywhere. Help!
Thank
you very much!