Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
FJ FJ is offline
external usenet poster
 
Posts: 90
Default Concatenate a range of cells with delimiter

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Concatenate a range of cells with delimiter

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
FJ FJ is offline
external usenet poster
 
Posts: 90
Default Concatenate a range of cells with delimiter

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
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
Function to concatenate cells in a range Leporello Excel Worksheet Functions 3 May 12th 23 07:42 PM
concatenate with a varying range of cells Riversage Excel Worksheet Functions 0 January 29th 07 07:43 PM
concatenate cells by a given range Twan Kennis Excel Worksheet Functions 4 July 1st 06 12:54 AM
Concatenate a Range of Cells Bob Stearns Excel Programming 4 January 27th 06 06:19 AM
How to concatenate adjacent cells in a range without using &? Ark Excel Worksheet Functions 4 October 16th 05 06:38 PM


All times are GMT +1. The time now is 08:52 AM.

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"