Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Copying and Pasting in a different worksheet (Urgent)

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying and Pasting in a different worksheet (Urgent)

I saw your value column as column E (5th column). If it is the 4th
column/column D, change
Worksheets("sheet2").Cells(rw, col) = Cells(i, 5).Value

to

Worksheets("sheet2").Cells(rw, col) = Cells(i, 4).Value

--
Regards,
Tom Ogilvy


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





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Copying and Pasting in a different worksheet (Urgent)

Hi
Tom

Thanyou very much it helped me a lot
I had one more query in this


It's as follows

Write now with that code it's copying in continous rows in other worksheet.
Like this

123 124 234
235 345 567
123


I want to do like this


1 Value 123 124 234
2
3 Value1 235 345..
4
5
6 Value 123
and so on

If you could help me on that
it would be great

Thanx a lot for providing me help.

"Tom Ogilvy" wrote:

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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying and Pasting in a different worksheet (Urgent)

do you want the literal term "Value" placed in column 1 (if so, why Value
in row 1 and Value1 in row3 then back to Value in row 6).

Also, how do you determine how many rows to skip. You skip one row ( 2),
then you skip two rows (4 and 5).

If there is a pattern there, I don't see it.

--
Regards,
Tom Ogilvy

"Lolly" wrote in message
...
Hi
Tom

Thanyou very much it helped me a lot
I had one more query in this


It's as follows

Write now with that code it's copying in continous rows in other

worksheet.
Like this

123 124 234
235 345 567
123


I want to do like this


1 Value 123 124 234
2
3 Value1 235 345..
4
5
6 Value 123
and so on

If you could help me on that
it would be great

Thanx a lot for providing me help.

"Tom Ogilvy" wrote:

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






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
Copying data from 1 worksheet and pasting to another skipping blan Concertgoer Excel Discussion (Misc queries) 1 October 1st 08 12:30 AM
holding worksheet formats when copying/pasting hsyrddy Excel Discussion (Misc queries) 2 November 28th 07 09:59 PM
Problems with copying and pasting dates from one worksheet to anot hroberto Excel Discussion (Misc queries) 1 March 6th 07 02:49 AM
Copying and Pasting a Worksheet Jim Pockmire Setting up and Configuration of Excel 1 September 8th 05 02:57 PM
Hided values appears when I'm copying/pasting it to other worksheet Aivaras_Bakanas Excel Discussion (Misc queries) 2 July 13th 05 02:18 PM


All times are GMT +1. The time now is 09:14 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"