title: VBA extract unique values based on criteria
body: <p>I want to get a list of distinct value based on a criteria, example : I have a list of stores, and i want to get only distinct value based on retailer criteria "BOULANGER".</p>
  
  <p><a href="https://i.stack.imgur.com/4Viv6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4Viv6.png" alt="enter image description here"></a></p>
  
  <pre><code>Sub distinctValues()
  
  Dim LastRow As Long
  Dim Crit1 As String
  
  LastRow = Sheets("SOURCE").Cells(Rows.Count, "B").End(xlUp).Row
  
  Sheets("SOURCE").Range("B1:B" &amp; LastRow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Sheets("TEST").Range("E2"), CopyToRange:=Sheets("TEST").Range("A12"), Unique:=True
  
  End Sub
  </code></pre>