Row count where data exists

前端 未结 7 1648
广开言路
广开言路 2021-02-08 19:24

I need to count the total number of rows that have data. I want to be able to use this on multiple sheets with different amounts of data rows.

I cannot figure out gener

7条回答
  •  梦毁少年i
    2021-02-08 19:32

    This works for me. Returns the number that Excel displays in the bottom status line when a pivot column is filtered and I need the count of the visible cells.

    Global Const DashBoardSheet = "DashBoard"
    Global Const ProfileColRng = "$L:$L"
    .
    .
    .
    Sub MySub()
    Dim myreccnt as long
    .
    .
    .
    myreccnt = GetFilteredPivotRowCount(DashBoardSheet, ProfileColRng)
    .
    .
    .
    End Sub
    
    Function GetFilteredPivotRowCount(sheetname As String, cntrange As String) As long
    
    Dim reccnt As Long
    
    reccnt = Sheets(sheetname).Range(cntrange).SpecialCells(xlCellTypeVisible).SpecialCells(xlCellTypeConstants).Count - 1
    
    GetFilteredPivotRowCount = reccnt
    
    End Function
    

提交回复
热议问题