Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default How to concatenate a range?

To sum up a range I can use SUM(A1:A30) but cells A1:A30 contain text
(strings).
The function CONCATENATE(A1:A30) does work here.
Is there a simple way to that without having to use Range("A1") &
Range("A2") & ..........Range("A30")?
Thanks,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How to concatenate a range?

Nathan,

I think you need to roll your own. Something like

Function Concat(ParamArray V()) As String
Dim Ndx As Long
Dim R As Range
Dim S As String
For Ndx = LBound(V) To UBound(V)
If TypeOf V(Ndx) Is Excel.Range Then
For Each R In V(Ndx).Cells
S = S & R.Text
Next R
Else
S = S & Format(V(Ndx))
End If
Next Ndx
Concat = S
End Function

You can then call this from a worksheet as
=Concat(A1:A10)


--

Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






"Nathan Gutman" wrote in message
...
To sum up a range I can use SUM(A1:A30) but cells A1:A30

contain text
(strings).
The function CONCATENATE(A1:A30) does work here.
Is there a simple way to that without having to use Range("A1")

&
Range("A2") & ..........Range("A30")?
Thanks,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default How to concatenate a range?

Thanks Chip, I was afraid of that.
On Thu, 18 Dec 2003 10:50:48 -0600, "Chip Pearson"
wrote:

Nathan,

I think you need to roll your own. Something like

Function Concat(ParamArray V()) As String
Dim Ndx As Long
Dim R As Range
Dim S As String
For Ndx = LBound(V) To UBound(V)
If TypeOf V(Ndx) Is Excel.Range Then
For Each R In V(Ndx).Cells
S = S & R.Text
Next R
Else
S = S & Format(V(Ndx))
End If
Next Ndx
Concat = S
End Function

You can then call this from a worksheet as
=Concat(A1:A10)


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 range (without UDF) Greg Lovern Excel Worksheet Functions 6 September 17th 09 05:36 PM
Concatenate with date range Pete@cadth Excel Discussion (Misc queries) 7 August 22nd 08 08:09 PM
function to concatenate range GoBobbyGo Excel Discussion (Misc queries) 2 April 19th 06 01:34 AM
concatenate a range function Wildaz Excel Worksheet Functions 7 March 15th 06 07:10 PM
Concatenate a range King Excel Worksheet Functions 3 March 11th 05 09:10 PM


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

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

About Us

"It's about Microsoft Excel"