问题描述:

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:
相关阅读:
Top