P
Peter
here is my sub, (thanks to Ryan H, et al, in post 23/9/08):
it finds the last full cell on sheet 1 and copies down to it and pastes the
result in the next avaialble col (rhs) on sheet 2.
**************************
Sub CopyCols()
Dim LRow As Long
Dim LCol As Long
' find last row in Col.A on Sheet1
LRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
' find last column in Row 1 on Sheet2
LCol = Sheets("Sheet2").Cells(1, Columns.Count).End(xlToLeft).Column
' copy range on Sheet1 and paste the range onto Sheet2
Sheets("Sheet1").Range("c1:e" & LRow).Copy _
Destination:=Sheets("Sheet2").Cells(1, LCol + 1)
End Sub
****************
this works perfectly, thanks guys, but i would like to automate it a bit
more and i just cannot figure out range cell referencing vis as vis cell
referencing.
can someone pls show me how to make a variable out of
Range("c1:e" & LRow). (no message boxes or userforms pls)
such that i can at the top of my code (or anywhere really) slip in the col
number or column numbers i want to copy and paste instead of changing the
range in the current specification. eg instead of going to the line "c1:e"
and putting in a range reference, i would like to just put into the code
somewhere that i want col 3 and col 5 and col 7 copied and be able to do it
again and again but with different col numbers.
ps i have in the past, learnt sas and spss but they were a piece of cake
compared to this. i am just finding it so so hard to learn. i have a couple
of books but am still having a lot of trouble getting my head around the
objects and methods etc. so sorry for asking really dumb questions. i guess
it will click all of a sudden. any tips to pick up referencing to cells
ranges etc would be good.
it finds the last full cell on sheet 1 and copies down to it and pastes the
result in the next avaialble col (rhs) on sheet 2.
**************************
Sub CopyCols()
Dim LRow As Long
Dim LCol As Long
' find last row in Col.A on Sheet1
LRow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
' find last column in Row 1 on Sheet2
LCol = Sheets("Sheet2").Cells(1, Columns.Count).End(xlToLeft).Column
' copy range on Sheet1 and paste the range onto Sheet2
Sheets("Sheet1").Range("c1:e" & LRow).Copy _
Destination:=Sheets("Sheet2").Cells(1, LCol + 1)
End Sub
****************
this works perfectly, thanks guys, but i would like to automate it a bit
more and i just cannot figure out range cell referencing vis as vis cell
referencing.
can someone pls show me how to make a variable out of
Range("c1:e" & LRow). (no message boxes or userforms pls)
such that i can at the top of my code (or anywhere really) slip in the col
number or column numbers i want to copy and paste instead of changing the
range in the current specification. eg instead of going to the line "c1:e"
and putting in a range reference, i would like to just put into the code
somewhere that i want col 3 and col 5 and col 7 copied and be able to do it
again and again but with different col numbers.
ps i have in the past, learnt sas and spss but they were a piece of cake
compared to this. i am just finding it so so hard to learn. i have a couple
of books but am still having a lot of trouble getting my head around the
objects and methods etc. so sorry for asking really dumb questions. i guess
it will click all of a sudden. any tips to pick up referencing to cells
ranges etc would be good.