FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,364
- Office Version
- 365
- 2016
- Platform
- Windows
This VBA code returns the unique values from column A of the CURRENT tab. How could I also get the results of column B that go with the results from column A? I would like to put those results in Cells(2, 5).
VBA Code:
Sub FilterLocation()
Dim Dn As Range
Dim rng As Range
Dim ws As Worksheet
Set ws = Sheets("CURRENT")
Set rng = ws.Range("A2", ws.Range("A" & ws.Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In rng
If Not .Exists(Dn.Value) _
And Dn.Offset(, 3).Value = Sheets("Sheet2").Range("B2").Value _
And Dn.Offset(, 4).Value = Sheets("Sheet2").Range("B3").Value Then
.Add Dn.Value, ""
End If
Next
Sheets("Sheet2").Cells(2, 6).Resize(.Count).Value = Application.Transpose(.keys)
End With
End Sub