我正在使用SpecialCells(xlCellTypeVisible)来仅获取可见的单元格。我的目标是在应用过滤条件后最多提取5条记录。
然而,在应用过滤器并且存在隐藏单元格之后,仅获取连续的单元格并且隐藏行之后的任何内容都不是 被拉了。
有没有办法跳过隐藏的单元格并获得最多5个条目。
Dim rRange As Range, filRange As Range
Dim value1 As String
Dim value2 As String
Dim strItemNameBF() As String
Dim iCol As Long
Dim iRow As Long
Dim loopCnt As Integer
Dim chk As String
Dim i As Integer
i = 0
Dim rAcells As Range
'Sheets("Test Log").Select
Sheets("Test Log").AutoFilterMode = False
Set rRange = Sheets("Test Log").Range("TestLog")
With rRange
.AutoFilter Field:=1, Criteria1:=projectID
.AutoFilter Field:=4, Criteria1:=Array("Red", "Yellow", "Green"), Operator:=xlFilterValues
Set filRange = .Offset(1, 0).SpecialCells(xlCellTypeVisible)
If filRange.Rows.Count > 0 Then
If filRange.Rows.Count > 5 Then
loopCnt = 5
Else
loopCnt = filRange.Rows.Count