ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   MERGING COLUMNS TO ONE (https://www.excelbanter.com/excel-discussion-misc-queries/233672-merging-columns-one.html)

Faraz A. Qureshi

MERGING COLUMNS TO ONE
 
Would one of you experts kindly devise me a code so as to merge the different
sizes of blocks of a table in a single column.

For example the source data is

A01 BX1 C2 D1
A02 BX2 D2
A03 BX3
A04 D3

What code could copy the columns onto some other location/sheet as follows:

A01
A02
A03
A04
BX1
BX2
BX3
C2
D1
D2
<<Blank Cell
D3

cpearson's outstanding the reversal, i.e. Column to Table at
http://www.cpearson.com/Excel/Variab...mnToTable.aspx
but I sure am making mistakes in having the said code modified to carry out
such exercise the other way around.

Thanx in advance.

--
Best Regards,

Faraz

Don Guillett

MERGING COLUMNS TO ONE
 
Option Explicit
Sub makeallcolumnsone()
Dim i, slr, dlr As Long
For i = 2 To _
Cells(1, Columns.Count).End(xlToLeft).Column
slr = Cells(Rows.Count, i).End(xlUp).Row
dlr = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(1, i).Resize(slr).Copy Cells(dlr, 1)
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Faraz A. Qureshi" wrote in
message ...
Would one of you experts kindly devise me a code so as to merge the
different
sizes of blocks of a table in a single column.

For example the source data is

A01 BX1 C2 D1
A02 BX2 D2
A03 BX3
A04 D3

What code could copy the columns onto some other location/sheet as
follows:

A01
A02
A03
A04
BX1
BX2
BX3
C2
D1
D2
<<Blank Cell
D3

cpearson's outstanding the reversal, i.e. Column to Table at
http://www.cpearson.com/Excel/Variab...mnToTable.aspx
but I sure am making mistakes in having the said code modified to carry
out
such exercise the other way around.

Thanx in advance.

--
Best Regards,

Faraz




All times are GMT +1. The time now is 08:04 AM.

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