Apologies if this has been answered already, but couldn't find it when I searched.
Sheet 2 has a five column database of records, with Project Numbers in Col A, and Client Names in Col C.
Following Code filters the database to show only the records matching whichever Client is selected in D3 of another sheet. Works perfectly at that point.
I then need to extract the "unique" Project Numbers from the filtered Col A, and copy the list to somewhere else, so I end up with a list of the Projects relating to the Client selected.
Option Explicit
Dim a As Long, b As Long, f As Long
Dim myrange As Range
Sub PROJECTLIST()
'FILTER THE DATABASE TO SHOW ONLY RECORDS RELATING TO THE CLIENT IN D3 ON SHEET 1:
Sheet2.Activate
With Sheet2
a = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1:E" & a).Select
Selection.AutoFilter
.Range("A1:E" & a).AutoFilter Field:=3, Criteria1:=Sheet1.Range("D3")
Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
'THEN NEED TO EXTRACT THE LIST OF UNIQUE PROJECT NUMBERS IN COL A OF THE FILTERED LIST:
With Range("A:A").SpecialCells(xlCellTypeConstants).Resize(, 5)
.AutoFilter Field:=1, Criteria1:='WHAT GOES HERE THAT WILL TELL IT TO FIND AND COPY UNIQUE RECORDS?
.Columns(1).SpecialCells(xlCellTypeVisible).Copy
With .Columns(8)
.PasteSpecial xlPasteValues
.RemoveDuplicates Columns:=Array(1), Header:=xlYes
End With
.AutoFilter
End With
End Sub
Any suggestions, pointers or alternative solutions welcome as ever
Ochimus
Bookmarks