View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Copying and Pasting in a different worksheet (Urgent)

Sub AAAA()
Dim lastrow As Long, s1 As Variant, s2 As Variant
Dim i As Long, col As Long, rw As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row

s1 = Cells(2, 1).Value
s2 = Cells(2, 2).Value
col = 0
rw = 1
For i = 2 To lastrow
If Cells(i, 1) = s1 And Cells(i, 2) = s2 Then
col = col + 1
Else
col = 1
rw = rw + 1
s1 = Cells(i, 1)
s2 = Cells(i, 2)
End If
Worksheets("sheet2").Cells(rw, col) = Cells(i, 5).Value
Next


End Sub

--
Regards,
Tom Ogilvy



"Lolly" wrote in message
...
Hi

My source data is like this

Sub Measure yr mo date Value
33 45 4 4 123
33 45 4 5 113
36 45 4 4 122
36 45 4 5 112


My question is I need to copy data in a different worksheet? When sub and
measure are same it needs to be copied in a same row of diff worksheet.

As
soon as anyone of them changes then it needs to be copied in a different

row
of diff worksheet

Any help would be appreciated
--
Kittie