ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   merging cells/data using a Macro (https://www.excelbanter.com/excel-programming/331445-merging-cells-data-using-macro.html)

crimsonkng

merging cells/data using a Macro
 
I have a 6,000-line macro. At a certain point, I need to merge data from
various cells into other cells.

I want to merge (append?) data/text from cells B1 and C1 onto existing text
in A1 but then delete B1 and C1 so that A1 "stretches" across that range
(A1:C1). I never know what the actual data/text will be in the cells, though.

So, let's say that:
A1 contains the words "I like"
B1 contains the words "chocolate" and
C1 contains the words "ice cream."

I want to end up with "I like chocolate ice cream" in Cell A1 and, in
effect, delete the text in B1 and C1 so that A1's text "carries over" into
those cells. Or, after joining (?) the data, merge A1, B1, and C1.

Of course, I can do it manually and "record a macro" but it records the
actual words but that won't work in real life because the words/text are
always different.

Thanks, in advance.

Dan

Andibevan[_2_]

merging cells/data using a Macro
 
Look at the text function concatenate - this can be used to link any number
of cells together in a contigiuos string

"crimsonkng" wrote in message
...
I have a 6,000-line macro. At a certain point, I need to merge data from
various cells into other cells.

I want to merge (append?) data/text from cells B1 and C1 onto existing text
in A1 but then delete B1 and C1 so that A1 "stretches" across that range
(A1:C1). I never know what the actual data/text will be in the cells,
though.

So, let's say that:
A1 contains the words "I like"
B1 contains the words "chocolate" and
C1 contains the words "ice cream."

I want to end up with "I like chocolate ice cream" in Cell A1 and, in
effect, delete the text in B1 and C1 so that A1's text "carries over" into
those cells. Or, after joining (?) the data, merge A1, B1, and C1.

Of course, I can do it manually and "record a macro" but it records the
actual words but that won't work in real life because the words/text are
always different.

Thanks, in advance.

Dan



crimsonkng

merging cells/data using a Macro
 
Sorry for taking up bandwith but, omigod, thanks Andi, that's awesome. Works
perfectly! Shame on me for not knowing that. Thanks a lot!

"Andibevan" wrote:

Look at the text function concatenate - this can be used to link any number
of cells together in a contigiuos string

"crimsonkng" wrote in message
...
I have a 6,000-line macro. At a certain point, I need to merge data from
various cells into other cells.

I want to merge (append?) data/text from cells B1 and C1 onto existing text
in A1 but then delete B1 and C1 so that A1 "stretches" across that range
(A1:C1). I never know what the actual data/text will be in the cells,
though.

So, let's say that:
A1 contains the words "I like"
B1 contains the words "chocolate" and
C1 contains the words "ice cream."

I want to end up with "I like chocolate ice cream" in Cell A1 and, in
effect, delete the text in B1 and C1 so that A1's text "carries over" into
those cells. Or, after joining (?) the data, merge A1, B1, and C1.

Of course, I can do it manually and "record a macro" but it records the
actual words but that won't work in real life because the words/text are
always different.

Thanks, in advance.

Dan





All times are GMT +1. The time now is 05:31 PM.

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