Find the next visible row

后端 未结 1 666
一整个雨季
一整个雨季 2021-01-23 05:20

I am trying to write a function to return the next visible row in an autofiltered list.

In a sheet with an autofiltered range the code below returns a #VALUE error:

相关标签:
1条回答
  • 2021-01-23 06:09

    Tthe following should accomplish what you are looking for.

    Public Function NextVisibleCell(Range As Range) As Range
    Application.Volatile
    Dim i As Long
    Set Range = Range.Cells(Range.Rows.Count, Range.Columns.Count)
    For i = 1 To Rows.Count - Range.Row
        If Not Range.Offset(i).EntireRow.Hidden Then
            Set NextVisibleCell = Range.Offset(i)
            Exit Function
        End If
    Next i
    End Function
    
    0 讨论(0)
提交回复
热议问题