当前位置: 动力学知识库 > 问答 > 编程问答 >

excel - Find row number of the empty row below a filtered table

问题描述:

I want to be able to find the row number of the first blank row under a filtered table. I was using this code, but it finds the final line of the filtered table.

.Range("A1").End(xlDown).Row

网友答案:

Here you go:

  Dim HeaderRow As Long, LastFilterRow As Long, Addresses() As String
  On Error GoTo NoFilterOnSheet
  With ActiveSheet
    HeaderRow = .AutoFilter.Range(1).Row
    LastFilterRow = .Range(Split(.AutoFilter.Range.Address, ":")(1)).Row
    Addresses = Split(.Range((HeaderRow + 1) & ":" & LastFilterRow). _
                      SpecialCells(xlCellTypeVisible).Address, "$")
    GetFilteredRangeBottomRow = Addresses(UBound(Addresses))
    FirstBlankRow = GetFilteredRangeBottomRow + 1
    MsgBox FirstBlankRow
  End With
NoFilterOnSheet:
分享给朋友:
您可能感兴趣的文章:
随机阅读: