View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Phrank Phrank is offline
external usenet poster
 
Posts: 153
Default Loop through a filtered range and copy unique values to a second sheet

That works brilliantly! My mind was totally focused on finding a
match (or not); didn't even think about counting. Very nice. As usual,
thank you very much, Claus!!

Frank

On Sat, 4 Jun 2016 11:19:40 +0200, Claus Busch
wrote:

Sub Macro5()
'
Dim wksQB As Worksheet, wksMDR As Worksheet
Dim rngC As Range, nameRange As Range
Dim LRow As Long

Set wksQB = ActiveWorkbook.Sheets("QueryBuster")
Set wksMDR = ActiveWorkbook.Sheets("MDR Worksheet")
LRow = wksQB.Cells(Rows.Count, "A").End(xlUp).Row
Set nameRange = wksQB.Range("E2:E" &
LRow).SpecialCells(xlCellTypeVisible)


For Each rngC In nameRange
If Application.CountIf(wksMDR.Range("A:A"), rngC) = 0 Then
wksMDR.Cells(Rows.Count, "A").End(xlUp)(2) = rngC
End If
Next
End Sub