Hi thenewbie22,
Welcome to the forum!! As per Marc L's Dictionary suggestion, try this:
Option Explicit
Sub Macro1()
Dim objMyUniqueData As Object
Dim rngMyCell As Range
Dim lngLastRow As Long
Dim varMyCol As Variant
Dim wsSourceSheet As Worksheet
Dim wsOutputSheet As Worksheet
Set wsSourceSheet = Sheets("Sheet1") 'Sheet name containing the data. Change to suit.
Set wsOutputSheet = Sheets("Sheet2") 'Sheet name for unique records to be pasted into. Change to suit.
On Error Resume Next 'In case there's no data on the tab
lngLastRow = wsSourceSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
On Error GoTo 0
If lngLastRow >= 2 Then 'Assumes data starts at Row 2. Change to suit.
Application.ScreenUpdating = False
Set objMyUniqueData = CreateObject("Scripting.Dictionary")
For Each varMyCol In Array("A", "E") 'Columns containing data. Change to suit.
For Each rngMyCell In wsSourceSheet.Range(varMyCol & "2:" & varMyCol & lngLastRow)
If Len(rngMyCell) > 0 Then
If objMyUniqueData.Exists(CStr(rngMyCell)) = False Then
objMyUniqueData.Add CStr(rngMyCell), rngMyCell
End If
End If
Next rngMyCell
Next varMyCol
'Output the unique records into Col. A of 'wsOutputSheet' tab. Change to suit.
wsOutputSheet.Range("A2").Resize(objMyUniqueData.Count) = Application.Transpose(objMyUniqueData.Items)
Application.ScreenUpdating = True
MsgBox objMyUniqueData.Count & " unique records have now been pasted into the """ & wsOutputSheet.Name & """ tab.", vbInformation
End If
End Sub
Just change the lines of code I've marked with "Change to suit" to meet your specific requirements (layout).
Regards,
Robert
Bookmarks