ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy multiple columns (https://www.excelbanter.com/excel-programming/384472-copy-multiple-columns.html)

Milax

copy multiple columns
 
Can somebody help me, I need to copy values from multiple columns to one
row, for example:

A1,B1,C1,D1
A2,B2,C2,D2
A3,B3,C3,D3

in

A1,B1,C1,D1,A2,B2,C2,D2,A3,B3,C3,D3.

I don't know witch object (Range or Cell) and its parameters to us.

Thanks!

Paul Morgan[_2_]

copy multiple columns
 

Here's a code that would work for you,

Remember that you only have 256 columns though you can ony do this fo
64 rows


Code
-------------------
Sub CutPasteToRowA()
Range("A2").Select
Do Until ActiveCell = ""
ActiveCell.Range("A1:D1").Cut Destination:=Range("A1").End(xlToRight).Offset(0, 1).Range("A1")
ActiveCell.Offset(1, 0).Select
Loop
Range("A1").Select
End Sub

-------------------

--
Paul Morga
-----------------------------------------------------------------------
Paul Morgan's Profile: http://www.officehelp.in/member.php?userid=519
View this thread: http://www.officehelp.in/showthread.php?t=136929

Posted from - http://www.officehelp.i


joel

copy multiple columns
 
Cell is index with a row number and a column number like Cells(1,3) which is
row 1 and column C.

Range has multiple for mats. the simple one is

Range("A3") where A3 is a character string. Range can also be made of cells
such as

Range(Cells(1,3),Cells(2,6))

I usually prefer to use a range with an offset such as

Range("A3:D3").offset(rowoffset:=2,columnoffset:=3 )

this format is nice because you can put it in a for loop and ichange the
rows or columns

for i = 1 to 10

Range("A3:D3").offset(rowoffset:=i,columnoffset:=3 )

Next i


Example 1
MyColoffset = 0
For RowCount = 1 To 3


Range("A1:D4").Offset(rowoffset:=RowCount - 1, columnoffset:=0).Copy _
Destination:=Range("A10"). _
Offset(rowoffset:=0, columnoffset:=4 * (RowCount - 1))


Next RowCount
newrange
next rowcount

Example 2

Set oldrange = Range("A1:D4")
Set newrange = Range("A10")
MyColoffset = 0
For RowCount = 1 To 3

oldrange.Offset(rowoffset:=RowCount - 1, columnoffset:=0).Copy _
Destination:=newrange. _
Offset(rowoffset:=0, columnoffset:=4 * (RowCount - 1))

Next RowCount
"Milax" wrote:

Can somebody help me, I need to copy values from multiple columns to one
row, for example:

A1,B1,C1,D1
A2,B2,C2,D2
A3,B3,C3,D3

in

A1,B1,C1,D1,A2,B2,C2,D2,A3,B3,C3,D3.

I don't know witch object (Range or Cell) and its parameters to us.

Thanks!



All times are GMT +1. The time now is 04:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com