Joining Columns one below the other

harshj

New Member
Joined
Apr 10, 2013
Messages
1
Imagine I have some columns of data. How can I stack multiple columns on below the other in column A?

For example, A column is blank now. B,C,D have some data.

ABCD
1abghij
2cdkl
3ef
4

<tbody>
</tbody>









Can all the columns be stacked in the empty column A?

A
1ab
2cd
3ef
4gh
5ij
6kl
7

<tbody>
</tbody>

This is just an example. I have 8000 columns in reality. Please help me with this. Thank you! :)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Here is a quick attempt:

Code:
Sub test()
    Dim x As Range, y As Range
    Set y = [A1]
    For Each x In [B1:D4]
        If Len(x.Value) > 0 Then
            Set y = y.Offset(1, 0)
            y.Value = x.Value
        End If
    Next x
End Sub

But it takes the values as they appear in rows, not columns...

ab
gh
ij

<tbody>
</tbody>
cd
kl
ef

<tbody>
</tbody>


<tbody>
</tbody>
 
Upvote 0
Here is code that will do it by column. You will need to change "[B1:D4]" to the actual address of your data. Also be careful that column "A" is empty or the data in it will be overwritten.


Code:
Sub test2()
    Dim x As Range, y As Range, z As Range
'   ------------------------------------------------------
    Set y = [A1]
    For Each z In [B1:D4].Columns
        For Each x In z.Cells
            If Len(x.Value) > 0 Then
                y.Value = x.Value
                Set y = y.Offset(1, 0)
            End If
        Next x
    Next z
End Sub
 
Upvote 0
Here is code that will do it by column. You will need to change "[B1:D4]" to the actual address of your data. Also be careful that column "A" is empty or the data in it will be overwritten.


Code:
Sub test2()
    Dim x As Range, y As Range, z As Range
'   ------------------------------------------------------
    Set y = [A1]
    For Each z In [B1:D4].Columns
        For Each x In z.Cells
            If Len(x.Value) > 0 Then
                y.Value = x.Value
                Set y = y.Offset(1, 0)
            End If
        Next x
    Next z
End Sub

How could I do this but link it to a column in a different workbook?
 
Upvote 0

Forum statistics

Threads
1,214,798
Messages
6,121,635
Members
449,043
Latest member
farhansadik

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top