Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy and Paste (Tom already in disscussion - more help needed)
This might work:
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 = 1 rw = 1 For i = 2 To lastrow If Cells(i, 1) = s1 And Cells(i, 2) = s2 Then col = col + 1 Else col = 2 rw = Worksheets("sheet2").Cells(rw, 1).End(xldown).row s1 = Cells(i, 1) s2 = Cells(i, 2) End If Worksheets("sheet2").Cells(rw, col) = Cells(i, 5).Value Next -- Regards, Tom Ogilvy "Lolly" wrote in message ... Hi, Tom Thanx for responding so quickly. I will tell you in detail the need for this: I have two excel worksheet. In one worksheet data comes the database.And the second worksheet is the template with some formating. Source data sample is as before which I had posted. Template worksheet in which data needs to be pulled is as follows 1 Goals 2 --- 3 Values 4--- 5--- 6 Data and so on Source data sheet(once again I am writing) 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 Output which I got in diff worksheet was 123 124 234 235 345 567 123 Output (Row wise data is fine).The above output I wanted to be not in continous rows. One problem is there is no sequence of the rows in which it needs to go. From this output Could you think of retrieving the data rowwise .With the position with the position somewhat like which I mentioned in the beginning.Output result is fine. I am trying to work on that type of template. Once again Tom thankyou very much. Regards Lolly "Tom Ogilvy" wrote: 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 -- Kittie |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy and Paste (Tom already in disscussion - more help needed)
Hi
Tom Thanx a lot for helping me. I wrote the code but it's not working. I will show the output which came with the following data source data: Sub Mes Yr Mo Da Profit 31 99 4 4 134 31 99 4 5 123 31 99 4 6 145 32 99 4 4 345 32 99 4 5 342 32 201 4 6 321 The put came like this in other worksheet: 1 123 145 145 2 3 4 5 6 7 345 342 Value 321 didn't show. If you could help me further then it will be of great help Regards Lolly "Tom Ogilvy" wrote: This might work: 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 = 1 rw = 1 For i = 2 To lastrow If Cells(i, 1) = s1 And Cells(i, 2) = s2 Then col = col + 1 Else col = 2 rw = Worksheets("sheet2").Cells(rw, 1).End(xldown).row s1 = Cells(i, 1) s2 = Cells(i, 2) End If Worksheets("sheet2").Cells(rw, col) = Cells(i, 5).Value Next -- Regards, Tom Ogilvy "Lolly" wrote in message ... Hi, Tom Thanx for responding so quickly. I will tell you in detail the need for this: I have two excel worksheet. In one worksheet data comes the database.And the second worksheet is the template with some formating. Source data sample is as before which I had posted. Template worksheet in which data needs to be pulled is as follows 1 Goals 2 --- 3 Values 4--- 5--- 6 Data and so on Source data sheet(once again I am writing) 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 Output which I got in diff worksheet was 123 124 234 235 345 567 123 Output (Row wise data is fine).The above output I wanted to be not in continous rows. One problem is there is no sequence of the rows in which it needs to go. From this output Could you think of retrieving the data rowwise .With the position with the position somewhat like which I mentioned in the beginning.Output result is fine. I am trying to work on that type of template. Once again Tom thankyou very much. Regards Lolly "Tom Ogilvy" wrote: 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 -- Kittie |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copy and Paste (Tom already in disscussion - more help needed)
My data looked like
SubMes Yr Mo Da Profit 31 99 4 4 134 '<== data starts on row 2 31 99 4 5 123 31 99 4 6 145 32 99 4 4 345 32 99 4 5 342 32 201 4 6 321 The destination sheet (template) looked like Value '<== string VALUE is in A1 Data Value1 all in column 1 -------------------------------------- Results looked like: Value 134 123 145 Data 345 342 Value1 321 Based on my interpretation of your situation, it worked for me. -- Regards, Tom Ogilvy "Lolly" wrote in message ... Hi Tom Thanx a lot for helping me. I wrote the code but it's not working. I will show the output which came with the following data source data: Sub Mes Yr Mo Da Profit 31 99 4 4 134 31 99 4 5 123 31 99 4 6 145 32 99 4 4 345 32 99 4 5 342 32 201 4 6 321 The put came like this in other worksheet: 1 123 145 145 2 3 4 5 6 7 345 342 Value 321 didn't show. If you could help me further then it will be of great help Regards Lolly "Tom Ogilvy" wrote: This might work: 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 = 1 rw = 1 For i = 2 To lastrow If Cells(i, 1) = s1 And Cells(i, 2) = s2 Then col = col + 1 Else col = 2 rw = Worksheets("sheet2").Cells(rw, 1).End(xldown).row s1 = Cells(i, 1) s2 = Cells(i, 2) End If Worksheets("sheet2").Cells(rw, col) = Cells(i, 5).Value Next -- Regards, Tom Ogilvy "Lolly" wrote in message ... Hi, Tom Thanx for responding so quickly. I will tell you in detail the need for this: I have two excel worksheet. In one worksheet data comes the database.And the second worksheet is the template with some formating. Source data sample is as before which I had posted. Template worksheet in which data needs to be pulled is as follows 1 Goals 2 --- 3 Values 4--- 5--- 6 Data and so on Source data sheet(once again I am writing) 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 Output which I got in diff worksheet was 123 124 234 235 345 567 123 Output (Row wise data is fine).The above output I wanted to be not in continous rows. One problem is there is no sequence of the rows in which it needs to go. From this output Could you think of retrieving the data rowwise .With the position with the position somewhat like which I mentioned in the beginning.Output result is fine. I am trying to work on that type of template. Once again Tom thankyou very much. Regards Lolly "Tom Ogilvy" wrote: 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 -- Kittie |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy-Paste Alternative Needed... | Excel Discussion (Misc queries) | |||
Excel formula to copy/paste formula needed please. | Excel Discussion (Misc queries) | |||
Copy and Paste help needed - tia! | Excel Worksheet Functions | |||
Excel cut/Paste Problem: Year changes after data is copy and paste | Excel Discussion (Misc queries) | |||
Urgent Help needed on! Copy and Paste a Formula as Values using a Loop statement | Excel Programming |