Removing Duplicate values from 2 ranges and creating a new range with the output

Mark McInerney

Active Member
Joined
Apr 4, 2012
Messages
259
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have data in range B1:C100. The data in b1:b100 has no duplicates. The data in c1:c100 has no duplicates. However there is some data in b1:b100 that is also contained in c1:c100

I'm looking for a formula to place in d1, and copy down, that will give me the unique values from each column b and c.

Is this possible?

Thanks - Mark.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Without formula, you could copy b1:b100 in D1 and c1:c100 in D101 and use
Data > Remove Duplicates

else use a macro
 
Last edited:
Upvote 0
Hi PCL - Thanks for taking a look.

When I use the duplicate function and record my actions on a macro it does not work correctly - there are still some duplicates. Is there a formula that might work instead??
 
Upvote 0
A formula will leave some cells empty, I think
Try next code
Code:
Sub Treat2()
   Range("D1").EntireColumn.ClearContents
   Range("B1:B100").Copy Destination:=Range("D1")
   Range("C1:C100").Copy Destination:=Range("D" & Rows.Count).End(3).Offset(1, 0)
   Range("D1:D" & Range("D" & Rows.Count).Row).RemoveDuplicates Columns:=1, Header:=xlNo
End Sub
 
Upvote 0
Oups, here better
Code:
Sub Treat2()
   Range("D1").EntireColumn.ClearContents
   Range("B1:B" & Range("B" & Rows.Count).End(3).Row).Copy Destination:=Range("D1")
   Range("C1:C" & Range("C" & Rows.Count).End(3).Row).Copy Destination:=Range("D" & Rows.Count).End(3).Offset(1, 0)
   Range("D1:D" & Range("D" & Rows.Count).End(3).Row).RemoveDuplicates Columns:=1, Header:=xlNo
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

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