Joint two column into one

Vanda_a

Well-known Member
Joined
Oct 29, 2012
Messages
934
Dear all

Please kindly adjust my code to a better one. Esp the red part. I have no idea how to deal with selected cells or range
Rich (BB code):
Sub Test()

Dim Row As Integer
Dim Col As Integer
Dim Cels As Range
Dim Rng As Range

Row = ActiveCell.Row
Col = ActiveCell.Column + 2
Set Rng = Range(Cells(ActiveCell.Row, ActiveCell.Column), Cells(ActiveCell.End(xlDown).Row, (ActiveCell.Column + 1))) ''In fact I want a selected range

For Each Cels In Rng
    Cells(Row, Col) = Cels
    Row = Row + 1
Next Cels

End Sub
The code does something like below table
ABC
11A1
22BA
33C2
44DB
55E3
6C
74
8D
95
10E

<tbody>
</tbody>
 
Last edited:
Yes... the range you are going to fill has twice as many cells as either column (when starting from Row 1, LastRow is also the number of cells in the column as well as being the row number for the last filled cell).
I see the point. Thank you very much
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Vanda_a,



Rich (BB code):
  .Range("D1").Resize(UBound(o, 1)).Value = o

It is a personal preference, and, it can be written several ways:

Rich (BB code):
  .Range("C1").Resize(UBound(o, 1)).Value = o
  
  .Range("C1").Resize(UBound(o, 1), UBound(o, 2)).Value = o
I see. Thank you so much
 
Upvote 0
Vanda_a,

Thanks for the feedback.

You are very welcome. Glad I could help.

And, come back anytime.
 
Upvote 0
Yes... the range you are going to fill has twice as many cells as either column (when starting from Row 1, LastRow is also the number of cells in the column as well as being the row number for the last filled cell).
Hello again.
Code:
  Application.Transpose(Split(Join(Evaluate( _
  "TRANSPOSE(A1:A" & LastRow & "&CHAR(1)&B1:B" & _
  LastRow & ")"), Chr(1)), Chr(1)))
Above code. I really cant understand by my own. Please kindly help to give me explanation step by step
Transpose shd be from left to right. Why above one from top to bottom?
 
Last edited:
Upvote 0
Split then Join. Split what text and join what text? Then transpose inside transpose. It pulls my hair off
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

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