Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default find duplicates and concatenate

I am trying to find all duplicates in a range R8:R1000 and then grab
the value in Column C of the the duplicate rows and concatenante them
all to the cell in S of that row

example
As you can see find each cell in range R8:R1000 and the grab value in
column C
and put all duplicates in column s
for each P1 in the range the results are 2,4,5 for each duplicate.


c d ....... r s (results)
2 P1 2,4,5
3 P2 3
12 P5 12,13
13 P5 12,13
4 P1 2,4,5
5 P1 2,4,5
10 P22 10


Any help would be great!


and "Go Wings"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default find duplicates and concatenate

Sub Cat_Dups()

For Each Cell1 In Range("R8:R1000")
CatStr = ""
For Each Cell2 In Range("R8:R1000")
If Cell1.Value = Cell2.Value Then
If CatStr = "" Then
CatStr = Range("C" & Cell2.Row).Value
Else
CatStr = CatStr & ", " & Range("C" & Cell2.Row).Value
End If
End If
Next Cell2
Cell1.Offset(0, 1).Value = CatStr
Next Cell1
End Sub


"rpick60" wrote:

I am trying to find all duplicates in a range R8:R1000 and then grab
the value in Column C of the the duplicate rows and concatenante them
all to the cell in S of that row

example
As you can see find each cell in range R8:R1000 and the grab value in
column C
and put all duplicates in column s
for each P1 in the range the results are 2,4,5 for each duplicate.


c d ....... r s (results)
2 P1 2,4,5
3 P2 3
12 P5 12,13
13 P5 12,13
4 P1 2,4,5
5 P1 2,4,5
10 P22 10


Any help would be great!


and "Go Wings"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default find duplicates and concatenate

On Jun 4, 11:39*pm, Joel wrote:
Sub Cat_Dups()

For Each Cell1 In Range("R8:R1000")
* *CatStr = ""
* *For Each Cell2 In Range("R8:R1000")
* * * If Cell1.Value = Cell2.Value Then
* * * * *If CatStr = "" Then
* * * * * * CatStr = Range("C" & Cell2.Row).Value
* * * * *Else
* * * * * * CatStr = CatStr & ", " & Range("C" & Cell2.Row).Value
* * * * *End If
* * * End If
* *Next Cell2
* *Cell1.Offset(0, 1).Value = CatStr
Next Cell1
End Sub



"rpick60" wrote:
I am trying to find all duplicates in a range R8:R1000 and then grab
the value in Column C of the the duplicate rows and concatenante them
all to the cell in S of that row


example
As you can see find each cell in range R8:R1000 and the grab value in
column C
and put all duplicates in column s
for each P1 in the range the results are 2,4,5 for each duplicate.


* c * * d ....... * r * * * * s (results)
* 2 * * * * * * * *P1 * * * * * 2,4,5
* 3 * * * * * * * *P2 * * * * * 3
* 12 * * * * * * *P5 * * * * * 12,13
* 13 * * * * * * *P5 * * * * * 12,13
* 4 * * * * * * * *P1 * * * * * 2,4,5
* 5 * * * * * * * *P1 * * * * * 2,4,5
*10 * * * * * * * P22 * * * * 10


Any help would be great!


and "Go Wings"- Hide quoted text -


- Show quoted text -


Joel
Thanks for th help. But i only get 1 value in column S. I am looking
for all of the duplicates to be listed.
Am i missing something
thanks again
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default find duplicates and concatenate

On Jun 5, 12:10*am, rpick60 wrote:
On Jun 4, 11:39*pm, Joel wrote:





Sub Cat_Dups()


For Each Cell1 In Range("R8:R1000")
* *CatStr = ""
* *For Each Cell2 In Range("R8:R1000")
* * * If Cell1.Value = Cell2.Value Then
* * * * *If CatStr = "" Then
* * * * * * CatStr = Range("C" & Cell2.Row).Value
* * * * *Else
* * * * * * CatStr = CatStr & ", " & Range("C" & Cell2.Row).Value
* * * * *End If
* * * End If
* *Next Cell2
* *Cell1.Offset(0, 1).Value = CatStr
Next Cell1
End Sub


"rpick60" wrote:
I am trying to find all duplicates in a range R8:R1000 and then grab
the value in Column C of the the duplicate rows and concatenante them
all to the cell in S of that row


example
As you can see find each cell in range R8:R1000 and the grab value in
column C
and put all duplicates in column s
for each P1 in the range the results are 2,4,5 for each duplicate.


* c * * d ....... * r * * * * s (results)
* 2 * * * * * * * *P1 * * * * * 2,4,5
* 3 * * * * * * * *P2 * * * * * 3
* 12 * * * * * * *P5 * * * * * 12,13
* 13 * * * * * * *P5 * * * * * 12,13
* 4 * * * * * * * *P1 * * * * * 2,4,5
* 5 * * * * * * * *P1 * * * * * 2,4,5
*10 * * * * * * * P22 * * * * 10


Any help would be great!


and "Go Wings"- Hide quoted text -


- Show quoted text -


Joel
Thanks for th help. But i only get 1 value in column S. I am looking
for all of the duplicates to be listed.
Am i missing something
thanks again- Hide quoted text -

- Show quoted text -


Joel
Sorry my mistake I figured it out.
It works great, thanks for the quick response
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default find duplicates and concatenate

It should work. Try an experiment by emptying some cell in column R. the
code presently considers two empty cell a duplicate. If this works, then the
cell do not equal each other in column R.

Also make sure you are looking at column S.

"rpick60" wrote:

On Jun 4, 11:39 pm, Joel wrote:
Sub Cat_Dups()

For Each Cell1 In Range("R8:R1000")
CatStr = ""
For Each Cell2 In Range("R8:R1000")
If Cell1.Value = Cell2.Value Then
If CatStr = "" Then
CatStr = Range("C" & Cell2.Row).Value
Else
CatStr = CatStr & ", " & Range("C" & Cell2.Row).Value
End If
End If
Next Cell2
Cell1.Offset(0, 1).Value = CatStr
Next Cell1
End Sub



"rpick60" wrote:
I am trying to find all duplicates in a range R8:R1000 and then grab
the value in Column C of the the duplicate rows and concatenante them
all to the cell in S of that row


example
As you can see find each cell in range R8:R1000 and the grab value in
column C
and put all duplicates in column s
for each P1 in the range the results are 2,4,5 for each duplicate.


c d ....... r s (results)
2 P1 2,4,5
3 P2 3
12 P5 12,13
13 P5 12,13
4 P1 2,4,5
5 P1 2,4,5
10 P22 10


Any help would be great!


and "Go Wings"- Hide quoted text -


- Show quoted text -


Joel
Thanks for th help. But i only get 1 value in column S. I am looking
for all of the duplicates to be listed.
Am i missing something
thanks again

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 2 columns (A2+B2) and compare for duplicates habelow1 Excel Discussion (Misc queries) 3 July 7th 09 05:48 PM
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 02:05 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"