convert different rows to one column

abokhadiga

New Member
Joined
Nov 25, 2009
Messages
4
Hello!

I'd like to convert the following rows:
1 2
7 9
5 6

to one column:
1
2
7
9
5
6

Any ideas? Even in VB?
TYIA!
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Code:
Sub test()
Dim r As Range, c As Range
Worksheets("sheet1").Activate
Set r = Range(Range("A1"), Range("A1").End(xlDown))
For Each c In r
Range(c, c.End(xlToRight)).Copy
With Worksheets("sheet2")
.Cells(Rows.Count, "a").End(xlUp).Offset(1, 0).PasteSpecial Transpose:=True
End With
Next c
Application.CutCopyMode = False
End Sub
 
Upvote 0
Thank you venkat1926!

I've tried the following code and it worked great for me:

Sub ToOneColumn()
Dim i As Long, k As Long, j As Integer
Application.ScreenUpdating = False
Columns(1).Insert
i = 0
k = 1
While Not IsEmpty(Cells(k, 2))
j = 2
While Not IsEmpty(Cells(k, j))
i = i + 1
Cells(i, 1) = Cells(k, j)
Cells(k, j).Clear
j = j + 1
Wend
k = k + 1
Wend
Application.ScreenUpdating = true
End Sub

The problem has been solved!
 
Upvote 0
Hi abokhadiga,

Please enjoy the forum.

You solved your problem to your own satisfaction with your own code.
That's very good!

I'd just like to note however, for your possible interest, that there are much shorter and faster ways to solve this type of problem.

For example vba code along these general lines
Code:
Sub xyz()
Dim e, k
For Each e In Range("A1").CurrentRegion
    k = k + 1
    Cells(k, "d") = e
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,135
Members
452,890
Latest member
Nikhil Ramesh

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