Описание
У меня есть лист с примерно 30 столбцами и в среднем более 500 тысяч строк (есть несколько файлов). Столбец 8 листа содержит имена файлов. Я применяю фильтр к этому столбцу, чтобы отображать только строки с именами файлов, которые я хочу видеть
Цель
После применения фильтра я хочу захватить все видимые строки в столбце 8 в массив. Это бит, с которым я борюсь с
Код
Sub GetFilteredColumn()
Dim oWS As Worksheet: Set oWS = ThisWorkbook.Worksheets("Sheet1")
Dim iLRow As Long, iRow As Long
Dim aFilTags As Variant
Dim oKey As Variant
Dim oDic As New Dictionary
With oWS
' Get row count of visible rows
iLRow = .AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count
' Check if any rows were returned after the filter
If iLRow > 1 Then
' Get column 8 of the filtered range into an array
' ** THIS is where i'm trying to capture column 8 into and array **
'aFilTags = .AutoFilter.Range
'aFilTags = .AutoFilter.Range.Columns(8).SpecialCells(xlCellTypeVisible).Rows
aFilTags = .Columns(8).SpecialCells(xlCellTypeVisible)
' Get unique values in dictionary
For iRow = 2 To UBound(aFilTags)
If Not oDic.Exists(aFilTags(iRow, 1)) Then
oDic.Add aFilTags(iRow, 1), aFilTags(iRow, 1)
End If
Next
' Display the unique list
iRow = 0
For Each oKey In oDic.Keys
iRow = iRow + 1
.Range("AZ" & iRow).Value = oDic(oKey)
Next
End If
End With
End Sub
К сожалению, я не могу поделиться рабочим листом из-за конфиденциальных данных в рабочей книге, но с удовольствием отвечу на любые вопросы. Спасибо, ребята