LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Concatenate without duplicates

Ron, you are correct and the corrected (duplicate handled) one looks good...

Did a small modification to the last line of mine so that the user can have
delimiter to be of any length.. like ", "

Function CONCATRANGE(rngRange As Range, _
Optional strDelimiter As String = " ", _
Optional blnAvoidBlank As Boolean = False, _
Optional blnAvoidDuplicates As Boolean = False)
Dim varTemp As Range, blnPass As Boolean

For Each varTemp In rngRange
blnPass = True
If blnAvoidBlank And Trim(varTemp) = vbNullString Then blnPass = False
If blnAvoidDuplicates Then
If InStr(1, CONCATRANGE & strDelimiter, strDelimiter & _
varTemp & strDelimiter, vbTextCompare) Then blnPass = False
End If
If blnPass Then CONCATRANGE = CONCATRANGE & strDelimiter & varTemp
Next
CONCATRANGE = Mid(CONCATRANGE, len(strDelimiter)+1)
End Function


If this post helps click Yes
---------------
Jacob Skaria


"Ron Rosenfeld" wrote:

On Thu, 1 Oct 2009 22:11:01 -0700, Jacob Skaria
wrote:

Hi Gord

Few points on the UDF

--Entries in sequence like orange, range will be considered as duplicates
which should be considered as different entries.


Agreed, and I've submitted a modification.



--To trim the first character off you can use mid(ConcatNonDups,2) instead of
Left(ConcatNonDups, Len(ConcatNonDups) - 1)


These are not equivalent.

Why would you want to trim the FIRST character?

Left(ConcatNonDups, Len(ConcatNonDups) - 1) trims the LAST character off, which
is appropriate for this routine.
--ron

 
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
find duplicates and concatenate rpick60 Excel Programming 4 June 5th 08 06:00 AM
find duplicates and concatenate rpick60 Excel Worksheet Functions 1 June 5th 08 03:28 AM
find duplicates and concatenate rpick60 Excel Worksheet Functions 0 June 5th 08 01:01 AM
Concatenate with no duplicates Bretter99 Excel Discussion (Misc queries) 10 July 26th 07 03:22 PM
Find Duplicates & Concatenate (cpm) sandy_eggo Excel Discussion (Misc queries) 1 August 4th 05 08:05 AM


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