View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Concatenate without duplicates

On Thu, 1 Oct 2009 18:52:01 -0700, QB wrote:

I have a table with cols A through J. I need to place in col J a
concatenation of Cols B through I, but without duplication as the same entry
could appear in multiple cols.

How can this be done?

Thank you,

QB


An extraneous line was in my previous submission. Corrected, and also changed
to comma-separation. Note that to change the separator to a ",<space" we now
have to trim off 2 characters at the end instead of 1.

========================
Option Explicit
Function ConcatNonDups(rg) As String
'Adds a line feed and no dups or blanks
Dim c As Range
For Each c In rg
If c.Text < 0 And _
WorksheetFunction.CountIf(rg, c.Text) = 1 Then
ConcatNonDups = ConcatNonDups & c.Text & ", "
'edit to suit
End If
Next c
ConcatNonDups = Left(ConcatNonDups, Len(ConcatNonDups) - 2)
End Function
===================================
--ron