Remove duplicate from list

hafe4k

New Member
Joined
Jan 7, 2019
Messages
26
Hi there,

I have 2 columns A and B column A has about 50 rows and column B has about 50 rows too. Some of the data appears in both column A and B, my aim is to get the data that are not duplicates and move them to column C, the data in the 2 fields does not directly match up from left to right and things in column a may be unique but things in column b may be unique too.

Column A | Column B | Column C
----------------------------------------------------
Alpha |Alpha | India
Bravo |Bravo | Romeo
Golf |Golf | Zulu
Romeo |India
Zulu

So how can I get only the unique fields from column A and Column B to appear in Column C?

Thanks guys
 
Yes, but please reply in this thread not through PM. So what new problems do you have?
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Thanks Akuini, just wanted a slight amendment, i am wanting to see the unique fields from each column in a separate column?
So in our example:

Column AColumn BColumn CColumn D
AlphaAlphaRomeoIndia
BravoBravoZulu
RomeoGolf
GolfIndia
Zulu

<tbody>
</tbody>
 
Upvote 0
Ok, try this:

Code:
[FONT=lucida console][COLOR=Royalblue]Sub[/COLOR] a1082893b()
[I][COLOR=seagreen]'https://www.mrexcel.com/forum/excel-questions/1082893-remove-duplicate-list.html[/COLOR][/I]
[COLOR=Royalblue]Dim[/COLOR] rr [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR], i [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR], j [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
[COLOR=Royalblue]Dim[/COLOR] x, va
[COLOR=Royalblue]Dim[/COLOR] d [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Object[/COLOR]

Application.ScreenUpdating = [COLOR=Royalblue]False[/COLOR]
rr = Range([COLOR=brown]"A:B"[/COLOR]).Find([COLOR=brown]"*"[/COLOR], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    va = Range([COLOR=brown]"A1:B"[/COLOR] & rr)
        [COLOR=Royalblue]Set[/COLOR] d = CreateObject([COLOR=brown]"scripting.dictionary"[/COLOR])
            d.CompareMode = vbTextCompare
    
 [COLOR=Royalblue]For[/COLOR] j = [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]To[/COLOR] [COLOR=crimson]2[/COLOR]
    [COLOR=Royalblue]For[/COLOR] i = [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]To[/COLOR] UBound(va, [COLOR=crimson]1[/COLOR])
        
        x = Trim(va(i, j))
        [COLOR=Royalblue]If[/COLOR] [COLOR=Royalblue]Not[/COLOR] d.Exists(x) [COLOR=Royalblue]Then[/COLOR]
            [COLOR=Royalblue]If[/COLOR] j = [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]Then[/COLOR] d(x) = [COLOR=crimson]1[/COLOR]
            [COLOR=Royalblue]If[/COLOR] j = [COLOR=crimson]2[/COLOR] [COLOR=Royalblue]Then[/COLOR] d(x) = [COLOR=crimson]2[/COLOR]
            [COLOR=Royalblue]Else[/COLOR]
            d(x) = [COLOR=crimson]3[/COLOR]
        [COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]If[/COLOR]
        
    [COLOR=Royalblue]Next[/COLOR]
 [COLOR=Royalblue]Next[/COLOR]
 
[COLOR=Royalblue]If[/COLOR] d.Exists([COLOR=brown]""[/COLOR]) [COLOR=Royalblue]Then[/COLOR] d.Remove [COLOR=brown]""[/COLOR]
i = [COLOR=crimson]0[/COLOR]: j = [COLOR=crimson]0[/COLOR]

Range([COLOR=brown]"C1:D"[/COLOR] & rr).ClearContents
    [COLOR=Royalblue]For[/COLOR] [COLOR=Royalblue]Each[/COLOR] x [COLOR=Royalblue]In[/COLOR] d
        [COLOR=Royalblue]If[/COLOR] d(x) = [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]Then[/COLOR] i = i + [COLOR=crimson]1[/COLOR]: Cells(i, [COLOR=brown]"C"[/COLOR]) = x
        [COLOR=Royalblue]If[/COLOR] d(x) = [COLOR=crimson]2[/COLOR] [COLOR=Royalblue]Then[/COLOR] j = j + [COLOR=crimson]1[/COLOR]: Cells(j, [COLOR=brown]"D"[/COLOR]) = x
    [COLOR=Royalblue]Next[/COLOR]
    
Application.EnableEvents = [COLOR=Royalblue]True[/COLOR]
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR][/FONT]
 
Upvote 0
Solution
Hi guys - was wondering if some advise or help please -
I'm working on a sheet - which will have data imports every month.
However when I import the new data is't important its in the same list view as the previous months - if things have moved I need to know so I can move the matched data from previous months accordingly so all still in sync?

How would I best run something which would tell me In Column C that whats in A & B are the same?

Would something like this work - any assistance with a query please? Or any better way of showing it?

CellColumn AColumn BLook at Column B and Compare positioning with A
1AlphaAlpha'Alpha' match same row
2BravoBravo'Bravo' match same row
3CharlieGolf'Charlie' removed - 'Golf' moved 'B3'
4GolfQuebec'Golf' moved 'B3' - 'Quebec' moved 'B4'
5PapaNovember'Papa' removed - 'November' NEW
6QuebecHotel'Quebec' moved B4 - 'Hotel' NEW
7ZuluZulu'Zulu' match same row
 
Upvote 0

Forum statistics

Threads
1,215,559
Messages
6,125,517
Members
449,236
Latest member
Afua

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