Macro to extract Unique Account Numbers

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,566
Office Version
  1. 2021
Platform
  1. Windows
I have account Numbers in Col A and in Col C. I need to compare these and extract into Col G , those that are unique to both Columns


I have tried to write code to compare the account numbers in Col A & C and extract those that are unique to both in Col G, but the code only copies the exact data that appears in Col A & C and not those that are unique to both these columns

When the unique records are extracted in Col G, I would also like the Col Number where the record was extracted to display in Col H

It would be appreciated if someone could kindly amend my code



Code:
 Sub Extract_Unique_ITEMS()
Sheets(14).Select

Range("A2:C" & Range("A" & Rows.Count).End(xlUp).Row).AdvancedFilter _
    Action:=xlFilterCopy, CopyToRange:=Range("G2"), Unique:=True
End Sub

See Sample Data of what the unique records should look like once extracted


Excel 2012
ABCDEFGH
1Mapping DataInput Data
2KNR-3004KNR-3024KNR-3004Col A
3KNR-3024KNR-3025KNR-3026Col A
4KNR-3025KNR-3064KNR-3027Col A
5KNR-3026KNR-3065KNR-3029Col A
6KNR-3027KNR-3066KNR-3067Col A
7KNR-3029KNR-3304KNR-3304Col B
8KNR-3064KNR-3305KNR-3305Col B
9KNR-3065KNR-3306KNR-3306Col B
10KNR-3066KNR-3514KNR-3514Col B
11KNR-3067KNR-3524KNR-3524Col B
12
13
14
15
Sheet1
 
Last edited:
Hi Ombir

Thanks for the code. It works perfectly
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,215,375
Messages
6,124,580
Members
449,174
Latest member
chandan4057

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