Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Compare List - Get Duplicate Values

I've used a variation of the following code to extract
unique items from two lists. Now, instead of capturing
the unique values going in to the collection, I would like
to capture everything that is not accepted into the
collection and put those values into a list. I've tried
to do this by adding error handling code without luck.
How could I rewrite this to capture all items not accepted
into the collection? Thanks.

Sub ListDuplicateVal()

Dim Rng1 As Range
Dim Rng2 As Range
Dim Cell As Range
Dim UniqueValues As New Collection

Set Rng1 = Range("B4:C10")
Set Rng2 = Range("E4")

On Error GoTo ErrorTrap
For Each Cell In Rng1
UniqueValues.Add Cell.Value, CStr(Cell.Value)
ErrorTrap:
Select Case Err
Case 457
Rng2.Value = Rng1.Value
Set Rng2 = Rng2.Offset(1, 0)
End Select

Next Cell

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Compare List - Get Duplicate Values

Sub ListDuplicateVal()

Dim Rng1 As Range
Dim Rng2 As Range
Dim Cell As Range
Dim UniqueValues As New Collection

Set Rng1 = Range("B4:C10")
Set Rng2 = Range("E4")
On Error Resume Next
For Each Cell In Rng1
UniqueValues.Add Cell.Value, CStr(Cell.Value)

Select Case Err
Case 457
Rng2.Value = Cell.Value
Set Rng2 = Rng2.Offset(1, 0)
End Select
Err.Clear
Next Cell
End Sub

--
Regards,
Tom Ogilvy

"John Mansfield" wrote in message
...
I've used a variation of the following code to extract
unique items from two lists. Now, instead of capturing
the unique values going in to the collection, I would like
to capture everything that is not accepted into the
collection and put those values into a list. I've tried
to do this by adding error handling code without luck.
How could I rewrite this to capture all items not accepted
into the collection? Thanks.

Sub ListDuplicateVal()

Dim Rng1 As Range
Dim Rng2 As Range
Dim Cell As Range
Dim UniqueValues As New Collection

Set Rng1 = Range("B4:C10")
Set Rng2 = Range("E4")

On Error GoTo ErrorTrap
For Each Cell In Rng1
UniqueValues.Add Cell.Value, CStr(Cell.Value)
ErrorTrap:
Select Case Err
Case 457
Rng2.Value = Rng1.Value
Set Rng2 = Rng2.Offset(1, 0)
End Select

Next Cell

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Compare List - Get Duplicate Values

Thank you Tom. I appreciate your help.

-----Original Message-----
Sub ListDuplicateVal()

Dim Rng1 As Range
Dim Rng2 As Range
Dim Cell As Range
Dim UniqueValues As New Collection

Set Rng1 = Range("B4:C10")
Set Rng2 = Range("E4")
On Error Resume Next
For Each Cell In Rng1
UniqueValues.Add Cell.Value, CStr(Cell.Value)

Select Case Err
Case 457
Rng2.Value = Cell.Value
Set Rng2 = Rng2.Offset(1, 0)
End Select
Err.Clear
Next Cell
End Sub

--
Regards,
Tom Ogilvy

"John Mansfield"

wrote in message
...
I've used a variation of the following code to extract
unique items from two lists. Now, instead of capturing
the unique values going in to the collection, I would

like
to capture everything that is not accepted into the
collection and put those values into a list. I've tried
to do this by adding error handling code without luck.
How could I rewrite this to capture all items not

accepted
into the collection? Thanks.

Sub ListDuplicateVal()

Dim Rng1 As Range
Dim Rng2 As Range
Dim Cell As Range
Dim UniqueValues As New Collection

Set Rng1 = Range("B4:C10")
Set Rng2 = Range("E4")

On Error GoTo ErrorTrap
For Each Cell In Rng1
UniqueValues.Add Cell.Value, CStr(Cell.Value)
ErrorTrap:
Select Case Err
Case 457
Rng2.Value = Rng1.Value
Set Rng2 = Rng2.Offset(1, 0)
End Select

Next Cell

End Sub



.

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
Eliminate duplicate values in drop down list irvine79 Excel Discussion (Misc queries) 1 February 3rd 09 09:30 PM
Compare a value to a list of values Jamie Excel Discussion (Misc queries) 1 July 8th 06 03:49 PM
Can I compare 2 lists to combine duplicate entries in new list? Tinytall Excel Worksheet Functions 0 May 13th 05 04:00 PM
How to find and list duplicate values in a list? Stefan[_6_] Excel Programming 1 May 14th 04 01:09 PM
How to find and list duplicate values in a list? Stefan[_6_] Excel Programming 1 May 14th 04 12:58 PM


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