Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 1
Default howto: concat (x1:x3)

I'm trying to construct a formula to concat text in a range of cells without
listing the cells individually in a comma-separated list, so that the formula
automatically takes into account newly inserted cells. concatenate(x1:x3)
results in a #VALUE error.

Any advice?

Thanks,
Marc
  #3   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 22,906
Default howto: concat (x1:x3)

Marc

CONCATENATE function will not take a range.

This User Defined Function will.

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

Usage is: =ConCatRange(X1:X3)

As rows or cells are inserted betweenX1 and X3, the X1:X3 will change to
accommodate.

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the above code in there. Save the
workbook and hit ALT + Q to return to Excel window.

Enter the formula as shown above.


Gord Dibben Excel MVP




On Fri, 15 Dec 2006 11:03:01 -0800, Marc Hebert <Marc
wrote:

I'm trying to construct a formula to concat text in a range of cells without
listing the cells individually in a comma-separated list, so that the formula
automatically takes into account newly inserted cells. concatenate(x1:x3)
results in a #VALUE error.

Any advice?

Thanks,
Marc


Gord Dibben MS Excel MVP
  #4   Report Post  
Posted to microsoft.public.excel.newusers
external usenet poster
 
Posts: 22,906
Default howto: concat (x1:x3)

Note:

As written the concatenated text will be comma de-limited.

Change If Len(cell.text) 0 Then sbuf = sbuf & cell.text & "," to " " for
space delimited.


Gord

On Fri, 15 Dec 2006 11:34:15 -0800, Gord Dibben <gorddibbATshawDOTca wrote:

Marc

CONCATENATE function will not take a range.

This User Defined Function will.

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

Usage is: =ConCatRange(X1:X3)

As rows or cells are inserted betweenX1 and X3, the X1:X3 will change to
accommodate.

If not familiar with VBA and macros, see David McRitchie's site for more on
"getting started".

http://www.mvps.org/dmcritchie/excel/getstarted.htm

In the meantime..........

To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

Hit CRTL + R to open Project Explorer.

Find your workbook/project and select it.

Right-click and InsertModule. Paste the above code in there. Save the
workbook and hit ALT + Q to return to Excel window.

Enter the formula as shown above.


Gord Dibben Excel MVP




On Fri, 15 Dec 2006 11:03:01 -0800, Marc Hebert <Marc
wrote:

I'm trying to construct a formula to concat text in a range of cells without
listing the cells individually in a comma-separated list, so that the formula
automatically takes into account newly inserted cells. concatenate(x1:x3)
results in a #VALUE error.

Any advice?

Thanks,
Marc


Gord Dibben MS Excel MVP


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
HowTo disable cell reference update Eggle Charts and Charting in Excel 0 October 4th 06 03:15 PM
HowTo add row to series data Eggle Charts and Charting in Excel 0 October 4th 06 03:08 PM
Concat Macro help... [email protected] Excel Discussion (Misc queries) 4 August 8th 06 05:09 PM
The question is an excel question that I need to figure out howto do in excel. Terry Excel Worksheet Functions 3 January 23rd 06 06:22 PM
Howto use excel cell value to lookup an oracle table Andre Excel Discussion (Misc queries) 0 April 5th 05 09:44 AM


All times are GMT +1. The time now is 06:08 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"