Unique list for each of the two compared columns

wfvdc

New Member
Joined
Nov 12, 2008
Messages
3
All,

I have searched and search and not found what I am looking for. But I khow there has to be an answer. I am routinely comparing two lists "Original" vs "New". I worte an VBA macro to apply column headers, make named ranges from the ranges, and then use conditional formatting to color the uniques red and the duplicates green and autofilter. The goal is to find all the uniques that are not on the other list. The issue I am having us incorporating a way to list all of the unique values on
A
B
c
d
e
1
Original
New
Unique on Original
Unique on New
2
1
2
1.625
2.3125
3
1.625
2.25
1.75
2.3125
4
1.75
2.3125
1.875
2.375
5
1.875
2.4375
2.125
2.4375
6
2
2.5
2.5
7
2.125
2.5625
2.5626
8
2.25
2.625
2.625

<TBODY>
</TBODY>


I have been manually applying the filter to find the uniques and the copying, then unapplying the filter, goting to D2 and then pasting the vlaues. Repeat for the other columns.

In Excel 2010, I have not found a way to display all the uniques in the respective unique columns. I have tried Interior.colorindex, Interior.color, FormatConditions(1).color and colorindex. I have tried testing the cell to see which rule is true with some prior version excel code. I have even tried uinsg macro recorder.

Can someone provide me with some code or a some info on how to accomplish the listing.

I perfer anything that that is VBA driven or that can be inserted into a cell with VBA. Ideally, Anything that loops through the named ranges to find the identified uniques and then puts them in the appropriate column.

Thanks,
Bill
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
This will put the unique items from column A into column D and the unique items from column B into column E.
Code:
Sub uniquorn()
Dim sh As Worksheet
Set sh = Sheets(1) 'Edit sheet name
    For Each c In Range("A2", sh.Range("A" & Rows.Count).End(xlUp))
        If Application.CountIf(sh.Range("B:B"), c.Value) = 0 Then
            sh.Cells(Rows.Count, 4).End(xlUp)(2) = c.Value
        End If
    Next
    For Each r In Range("B2", sh.Range("B" & Rows.Count).End(xlUp))
        If Application.CountIf(sh.Range("A:A"), r.Value) = 0 Then
            sh.Cells(Rows.Count, 5).End(xlUp)(2) = r.Value
        End If
    Next
End Sub
 
Upvote 0
Worked Perfectly. I didn't mention at the time, but I am creating the sheet tab names with vba based on input variables for the named ranges. However, all I had to do was modify

Code:
Set sh = Sheets(1) 'Edit sheet name

to

Code:
Set sh = ActiveWorkbook.Sheets(NewSheetName)

Thank you so much for your code and time!
 
Upvote 0

Forum statistics

Threads
1,215,473
Messages
6,125,018
Members
449,203
Latest member
tungnmqn90

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top