ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop thru filtered sheet, copy unique values to another sheet (https://www.excelbanter.com/excel-programming/451481-loop-thru-filtered-sheet-copy-unique-values-another-sheet.html)

Phrank

Loop thru filtered sheet, copy unique values to another sheet
 
Hi,

Sub Macro5()
'

Dim nameRange As Range
Dim wksQB As Worksheet
Dim wksMDR As Worksheet
Dim var As Variant
Dim cell As Range

Set wksQB = ActiveWorkbook.Sheets("QueryBuster")
Set wksMDR = ActiveWorkbook.Sheets("MDR Worksheet")
Set nameRange = wksQB.Range("E2",
Range("A65536").End(xlUp)).SpecialCells(xlCellType Visible)

wksQB.Range(nameRange).Select

For Each cell In nameRange
var = Application.Match(cell, wksMDR.Columns(1), 0)
If Not IsError(var) Then GoTo NextVar
ActiveCell.Value = wksMDR.Range("A2",
Range("A65536").End(xlUp).Offset(1, 0)).Value
NextVar:
Next cell

End Sub


All times are GMT +1. The time now is 08:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com