PC Review


Reply
Thread Tools Rate Thread

Concatenate a range of cells with delimiter

 
 
=?Utf-8?B?Rko=?=
Guest
Posts: n/a
 
      8th Dec 2006
Hi, I would like to concatenate a long range of cells using a semicolon to
separate each number. I have come across several macros online that will do
this, but none have included a delimiter in the code and, unfortunately, I
don't know enough about VBA to make any modifications. Does anyone know of a
way to do this? Thanks in advance for any information.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFydGluIEZpc2hsb2Nr?=
Guest
Posts: n/a
 
      9th Dec 2006
FJ:

Try this, I've set an optional sperator so that you can specify another
sperator.

Function concat(rRange As Range, Optional szSeperator As String = ";")

Dim szAns As String
Dim rCell As Range

On Error GoTo error_line

For Each rCell In rRange
szAns = szAns & rCell.Value & szSeperator
Next rCell

concat = Left(szAns, Len(szAns) - Len(szSeperator))

error_line:

End Function

--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"FJ" wrote:

> Hi, I would like to concatenate a long range of cells using a semicolon to
> separate each number. I have come across several macros online that will do
> this, but none have included a delimiter in the code and, unfortunately, I
> don't know enough about VBA to make any modifications. Does anyone know of a
> way to do this? Thanks in advance for any information.

 
Reply With Quote
 
=?Utf-8?B?Rko=?=
Guest
Posts: n/a
 
      9th Dec 2006
Hi, Martin, thank you so much! It's just what I needed! I really
appreciate it!



"Martin Fishlock" wrote:

> FJ:
>
> Try this, I've set an optional sperator so that you can specify another
> sperator.
>
> Function concat(rRange As Range, Optional szSeperator As String = ";")
>
> Dim szAns As String
> Dim rCell As Range
>
> On Error GoTo error_line
>
> For Each rCell In rRange
> szAns = szAns & rCell.Value & szSeperator
> Next rCell
>
> concat = Left(szAns, Len(szAns) - Len(szSeperator))
>
> error_line:
>
> End Function
>
> --
> Hope this helps
> Martin Fishlock
> Please do not forget to rate this reply.
>
>
> "FJ" wrote:
>
> > Hi, I would like to concatenate a long range of cells using a semicolon to
> > separate each number. I have come across several macros online that will do
> > this, but none have included a delimiter in the code and, unfortunately, I
> > don't know enough about VBA to make any modifications. Does anyone know of a
> > way to do this? Thanks in advance for any information.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function to concatenate cells in a range Leporello Microsoft Excel Worksheet Functions 3 14th Jul 2011 06:42 PM
concatenate with a varying range of cells =?Utf-8?B?Uml2ZXJzYWdl?= Microsoft Excel Worksheet Functions 0 29th Jan 2007 07:43 PM
concatenate cells by a given range Twan Kennis Microsoft Excel Worksheet Functions 4 1st Jul 2006 12:54 AM
Concatenate a Range of Cells Bob Stearns Microsoft Excel Programming 4 27th Jan 2006 06:19 AM
How to concatenate adjacent cells in a range without using &? =?Utf-8?B?QXJr?= Microsoft Excel Worksheet Functions 4 16th Oct 2005 06:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:25 AM.