Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 20
Default Repeating a concatenate function

Any ideas out there? I have a spreadsheet with an unknown number of rows
(1-100). I am trying to concatenate in one cell the output of each row. I
can use a count function to tell me how many rows to concantenate, but is
there some type of repeat function that will move down one row each time?
ie. if i have the following names in Column A, I want this result in Column C.

"A" "B" "C"
Carl Carl, Nick, Fred, Sam
Nick
Fred
Sam

Thanks in advanced
--

Topher
If you have questions, Someone has answers
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Repeating a concatenate function

I would just write a macro to loop round the appropriate number of
times - looping is something Excel isn't good at doing but if you
combine the power of simple macros and the functionality of Excel,
there's not much you can't achieve. If you haven't used macros before,
simply record one and edit the results. The syntax for addressing
particular cells and creating loops is pretty straightforward.

Mike

Topher wrote:
Any ideas out there? I have a spreadsheet with an unknown number of rows
(1-100). I am trying to concatenate in one cell the output of each row. I
can use a count function to tell me how many rows to concantenate, but is
there some type of repeat function that will move down one row each time?
ie. if i have the following names in Column A, I want this result in Column C.

"A" "B" "C"
Carl Carl, Nick, Fred, Sam
Nick
Fred
Sam

Thanks in advanced
--

Topher
If you have questions, Someone has answers


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4
Default Repeating a concatenate function

I would just write a macro to loop round the appropriate number of
times - looping is something Excel isn't good at doing but if you
combine the power of simple macros and the functionality of Excel,
there's not much you can't achieve. If you haven't used macros before,
simply record one and edit the results. The syntax for addressing
particular cells and creating loops is pretty straightforward.

Mike

Topher wrote:
Any ideas out there? I have a spreadsheet with an unknown number of rows
(1-100). I am trying to concatenate in one cell the output of each row. I
can use a count function to tell me how many rows to concantenate, but is
there some type of repeat function that will move down one row each time?
ie. if i have the following names in Column A, I want this result in Column C.

"A" "B" "C"
Carl Carl, Nick, Fred, Sam
Nick
Fred
Sam

Thanks in advanced
--

Topher
If you have questions, Someone has answers


  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 176
Default Repeating a concatenate function

You can create a UDF to perform this. To do this follow these steps:

1) Alt-F11
2) In the left pane right click on your sheet name and choose <Insert<Module
3) Paste the following code:

Function concat(rng As Range)
For Each rng In rng
temp = temp & rng & ", "
Next
concat = Left(temp, Len(temp) - 2)
End Function

4) Then you can use the function concat() within your sheet (e.g.
=concat(A1:A10))
--
Regards,
Dave


"Topher" wrote:

Any ideas out there? I have a spreadsheet with an unknown number of rows
(1-100). I am trying to concatenate in one cell the output of each row. I
can use a count function to tell me how many rows to concantenate, but is
there some type of repeat function that will move down one row each time?
ie. if i have the following names in Column A, I want this result in Column C.

"A" "B" "C"
Carl Carl, Nick, Fred, Sam
Nick
Fred
Sam

Thanks in advanced
--

Topher
If you have questions, Someone has answers

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Repeating a concatenate function

David

A small problem with your UDF..............

If any cells are blank in the A1:A10 range you get extra commas.

I.e. a,b,c,,,g,h,i,j

This modified UDF does not have that problem.

Function ConCatRange(CellBlock As Range) As String
Dim Cell As Range
Dim sbuf As String
For Each Cell In CellBlock
If Len(Cell.text) 0 Then sbuf = sbuf & Cell.text & ","
Next
ConCatRange = Left(sbuf, Len(sbuf) - 1)
End Function


Gord Dibben MS Excel MVP


On Thu, 17 Aug 2006 10:41:02 -0700, David Billigmeier
wrote:

You can create a UDF to perform this. To do this follow these steps:

1) Alt-F11
2) In the left pane right click on your sheet name and choose <Insert<Module
3) Paste the following code:

Function concat(rng As Range)
For Each rng In rng
temp = temp & rng & ", "
Next
concat = Left(temp, Len(temp) - 2)
End Function

4) Then you can use the function concat() within your sheet (e.g.
=concat(A1:A10))




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default Repeating a concatenate function

Gord Dibben wrote...
....
This modified UDF does not have that problem.

....

But it's not general. Why not make the comma delimiter another
argument? But then again, why restrict the udf unnecessarily to ranges?
Also, what happens if the OP *wants* to include blank fields between
comma separators? Choice is good.

The mcat udf in

http://groups.google.com/group/micro...456a9e326b19a6

(or http://makeashorterlink.com/?C6B84239D ) would allow for variable
number of arguments, and could be used for this specific task in an
array formula like

=SUBSTITUTE(TRIM(mcat(A1:A8&" "))," ",", ")

or just

=SUBSTITUTE(mcat(A1:A8&" ")," ",", ")

if blank fields should be included.

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
numerical integration integreat Excel Discussion (Misc queries) 4 May 12th 06 02:40 AM
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
MS Excel "Concatenate" function Wordgeek Excel Discussion (Misc queries) 1 September 23rd 05 04:51 PM
Date & Time mully New Users to Excel 4 May 23rd 05 11:56 AM
Automatically up date time in a cell Mark Excel Discussion (Misc queries) 5 May 12th 05 12:26 AM


All times are GMT +1. The time now is 01:34 AM.

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"