查找筛选表下方空行的行号

时间:2014-08-29 11:18:28

标签: excel excel-vba vba

我希望能够在筛选表下找到第一个空行的行号。我正在使用此代码,但它找到了过滤表的最后一行。

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

1 个答案:

答案 0 :(得分:1)

你走了:

  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: