Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default concatenate from one cell to another

I have a workbook with over 3000 rows of data. Many of the rows have data
that needs to be concatenated into what I will call the parent cell. For
example:

A1 contains a person's name and the remainder of that row contains all the
other information related to that name.
A2 contains an additional name that needs to be concatenated with the name
in A1, seperated by a semi-colon.
A3 - A6, 7, etc may contain additional names that also need to be
concatenated with the names in A1.

I know how to write a formula to concatenate one cell's data to another, but
what I don't know how to do is to deal with a variable number of rows whose
data needs to be concatenated to a cell in the "parent" row. And since the
number of rows will vary from 2 to as many as 6, that makes the problem more
difficult - at least for me.

What I would like is a macro (or actually several macros) that, when I put
the cursor in the parent cell and press a Ctrl-?? will copy the number of
cells I need, concatenate those cells contents into the parent cell and
delete the rows that the data was in before concatenation.

Your help is much appreciated.

David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default concatenate from one cell to another

David,
If you select a range of cells, this will concatenate 2nd to
the last to first cell and then delete other cells.

HTH

Sub ConcatenateRange()
Dim rng As Range
Set rng = Selection
For i = 2 To rng.Count
rng(1) = rng(1) & ";" & rng(i)
Next i
rng(2).Resize(rng.Count - 1).EntireRow.Delete
End Sub
"David Vollmer" wrote:

I have a workbook with over 3000 rows of data. Many of the rows have data
that needs to be concatenated into what I will call the parent cell. For
example:

A1 contains a person's name and the remainder of that row contains all the
other information related to that name.
A2 contains an additional name that needs to be concatenated with the name
in A1, seperated by a semi-colon.
A3 - A6, 7, etc may contain additional names that also need to be
concatenated with the names in A1.

I know how to write a formula to concatenate one cell's data to another, but
what I don't know how to do is to deal with a variable number of rows whose
data needs to be concatenated to a cell in the "parent" row. And since the
number of rows will vary from 2 to as many as 6, that makes the problem more
difficult - at least for me.

What I would like is a macro (or actually several macros) that, when I put
the cursor in the parent cell and press a Ctrl-?? will copy the number of
cells I need, concatenate those cells contents into the parent cell and
delete the rows that the data was in before concatenation.

Your help is much appreciated.

David

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default concatenate from one cell to another

Thank you, Toppers! That works great! You have just saved me a lot of work.

"Toppers" wrote:

David,
If you select a range of cells, this will concatenate 2nd to
the last to first cell and then delete other cells.

HTH

Sub ConcatenateRange()
Dim rng As Range
Set rng = Selection
For i = 2 To rng.Count
rng(1) = rng(1) & ";" & rng(i)
Next i
rng(2).Resize(rng.Count - 1).EntireRow.Delete
End Sub


"David Vollmer" wrote:

I have a workbook with over 3000 rows of data. Many of the rows have data
that needs to be concatenated into what I will call the parent cell. For
example:

A1 contains a person's name and the remainder of that row contains all the
other information related to that name.
A2 contains an additional name that needs to be concatenated with the name
in A1, seperated by a semi-colon.
A3 - A6, 7, etc may contain additional names that also need to be
concatenated with the names in A1.

I know how to write a formula to concatenate one cell's data to another, but
what I don't know how to do is to deal with a variable number of rows whose
data needs to be concatenated to a cell in the "parent" row. And since the
number of rows will vary from 2 to as many as 6, that makes the problem more
difficult - at least for me.

What I would like is a macro (or actually several macros) that, when I put
the cursor in the parent cell and press a Ctrl-?? will copy the number of
cells I need, concatenate those cells contents into the parent cell and
delete the rows that the data was in before concatenation.

Your help is much appreciated.

David

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Concatenate text cell and formula cell result GoinCrazy Excel Worksheet Functions 4 November 26th 08 04:27 PM
Concatenate and empty cell Fish Excel Discussion (Misc queries) 4 January 15th 08 04:42 AM
How to concatenate a value in cell ub Excel Worksheet Functions 4 May 29th 07 05:32 PM
How to concatenate a url and the value of another cell hwest13 New Users to Excel 2 June 3rd 05 09:11 PM
concatenate cell valmont Excel Worksheet Functions 2 March 11th 05 03:25 PM


All times are GMT +1. The time now is 07:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"