VBA: Pull unique records from one column matching another column

FryGirl

Well-known Member
Joined
Nov 11, 2008
Messages
1,368
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
This code works find to extract unique records out of column R (Sheet FY17), but I need to also match column D (Sheet FY17) against the value in AG1 (Sheet Workcount).

Any thoughts?

Code:
Sub FilterUnique()
    Dim rng As Range, Dn As Range
    With Sheets("FY17")
        Set rng = .Range(.Range("R2"), .Range("R" & .Rows.Count).End(xlUp))
    End With
    Debug.Print rng.Address
    With CreateObject("scripting.dictionary")
        .CompareMode = vbTextCompare
        For Each Dn In rng
            If Not .exists(Dn.Value) Then
                .Add Dn.Value, ""
            End If
        Next
        Sheets("Workcount").Range("AG2").Resize(.Count).Value = Application.Transpose(.keys)
    End With
End Sub
 
Last edited:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try
Code:
If Not .Exists(Dn.Value) And Dn.Offset(, -14).Value = Sheets("Workcount").Range("AG1").Value Then
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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