ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Return unique values from 2 different ranges (https://www.excelbanter.com/excel-programming/426324-return-unique-values-2-different-ranges.html)

John[_140_]

Return unique values from 2 different ranges
 
I have 3 different ranges, say Col C, F and G, that contain duplicate text
entries. How can I make a worksheet list of the unique entries?



RyGuy

Return unique values from 2 different ranges
 
Not a lot to go on here. Some dupes in the three columns? Dupes in each
column, but not in other columns? It can get a lot more complex too. You
can start with this and see if it does what you need:

Notice: before trying the code...Backup!! Backup!! Backup!!

Sub Uniques()
Dim i As Integer
i = 1
Do Until Cells(i, 1).Value = "" '(as long as your data is in column 1)
If Cells(i, 1) = Cells(i + 1, 1) Then
Else
Cells(i, 1).Copy
Cells(i, 5).PasteSpecial xlValues '(this pastes into column E)
End If
i = i + 1

Loop
Range("E5:E1000").Sort Key1:=Range("E5"), Order1:=xlAscending

Columns("E:E").Select
Selection.Sort Key1:=Range("E1"), Order1:=xlAscending ',
Header:=xlGuess, _

Range("A1").Select

End Sub

Sub ExtractUniqueAndSort()
With Sheets("Unique List#1")
..Range("A1:A20").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=.Range("E1"), _
Unique:=True

..Range(.Range("E1"), .Range("E1").End(xlDown)) _
..Sort Key1:=.Range("E2"), Order1:=xlAscending, Header:=xlYes
End With
End Sub

I am assuming that all data is in Column A, so change the macro accordingly,
or copy/paste your data into column A.

Good luck,
Ryan---


"John" wrote:

I have 3 different ranges, say Col C, F and G, that contain duplicate text
entries. How can I make a worksheet list of the unique entries?





All times are GMT +1. The time now is 02:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com