ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   copy text in multiple columns into one column (https://www.excelbanter.com/excel-discussion-misc-queries/167357-copy-text-multiple-columns-into-one-column.html)

CherylH

copy text in multiple columns into one column
 
I have the following:

Col #1 Col #2 Col #3
Z1 ZA ZM
Z2 ZB ZN

I want it to be in ONE column:
Col #1
Z1
Z2
ZA
ZB
ZM
ZN

Can I automatically do this vs. manually cutting and pasting?

Thanks in advance for any help!
Cheryl

Otto Moehrbach

copy text in multiple columns into one column
 
Cheryl
This macro will do what you want. This macro operates with Columns A:C
putting all in Column B and Column C into Column A along with what was in
Column A to start. HTH Otto
Sub ShiftData()
Dim rColB As Range
Dim rColC As Range
Set rColB = Range("B1", Range("B" & Rows.Count).End(xlUp))
Set rColC = Range("C1", Range("C" & Rows.Count).End(xlUp))
rColB.Copy Range("A" & Rows.Count).End(xlUp).Offset(1)
rColC.Copy Range("A" & Rows.Count).End(xlUp).Offset(1)
Columns("B:B").ClearContents
Columns("C:C").ClearContents
End Sub

"CherylH" wrote in message
...
I have the following:

Col #1 Col #2 Col #3
Z1 ZA ZM
Z2 ZB ZN

I want it to be in ONE column:
Col #1
Z1
Z2
ZA
ZB
ZM
ZN

Can I automatically do this vs. manually cutting and pasting?

Thanks in advance for any help!
Cheryl




CherylH

copy text in multiple columns into one column
 
Otto,
Many thanks! This worked perfectly!

"Otto Moehrbach" wrote:

Cheryl
This macro will do what you want. This macro operates with Columns A:C
putting all in Column B and Column C into Column A along with what was in
Column A to start. HTH Otto
Sub ShiftData()
Dim rColB As Range
Dim rColC As Range
Set rColB = Range("B1", Range("B" & Rows.Count).End(xlUp))
Set rColC = Range("C1", Range("C" & Rows.Count).End(xlUp))
rColB.Copy Range("A" & Rows.Count).End(xlUp).Offset(1)
rColC.Copy Range("A" & Rows.Count).End(xlUp).Offset(1)
Columns("B:B").ClearContents
Columns("C:C").ClearContents
End Sub

"CherylH" wrote in message
...
I have the following:

Col #1 Col #2 Col #3
Z1 ZA ZM
Z2 ZB ZN

I want it to be in ONE column:
Col #1
Z1
Z2
ZA
ZB
ZM
ZN

Can I automatically do this vs. manually cutting and pasting?

Thanks in advance for any help!
Cheryl






All times are GMT +1. The time now is 05:27 AM.

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