ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   crosstable to column (https://www.excelbanter.com/excel-programming/358079-crosstable-column.html)

bernieb[_2_]

crosstable to column
 
hello everybody
I have a little problem, I have a table in my excel worksheet,
like this for example:
1 2 3 4
5 6 7 8
where the number of rows and columns can vary.
I would like to transform this table in one column, like this:
1
5
2
6
3
7
4
8
Can anybody help me? Do I need a macro for this?
Thanks a lot
bernie


Dave Peterson

crosstable to column
 
Maybe something like:

Option Explicit
Sub testme()

Dim iCol As Long
Dim LastCol As Long
Dim DestCell As Range
Dim CurWks As Worksheet
Dim NewWks As Worksheet

Set CurWks = Worksheets("sheet1")
Set NewWks = Worksheets.Add

With CurWks
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
For iCol = 1 To LastCol
With NewWks
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp)
If IsEmpty(DestCell.Value) Then
'do nothing
Else
Set DestCell = DestCell.Offset(1, 0)
End If
End With
.Range(.Cells(1, iCol), .Cells(.Rows.Count, iCol).End(xlUp)).Copy _
Destination:=DestCell
Next iCol
End With

End Sub


bernieb wrote:

hello everybody
I have a little problem, I have a table in my excel worksheet,
like this for example:
1 2 3 4
5 6 7 8
where the number of rows and columns can vary.
I would like to transform this table in one column, like this:
1
5
2
6
3
7
4
8
Can anybody help me? Do I need a macro for this?
Thanks a lot
bernie


--

Dave Peterson


All times are GMT +1. The time now is 03:59 PM.

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