Counting and suming number of visible rows

  • Hello,



    The code below counts the number of rows, my question is, how would you count the number of visible rows?



    Code
    Totalrows = ch1.Range("D" & Rows.count).End(xlUp).Row


    also


    How would you calculate the sum of the visible rows in column D, from D2 downwards?


    I'm trying to write a formula,


    Code
    Prob = "Subtotal sum of column D" / "The number of visible cells"


    Thanks for the help



    also posted here : http://www.mrexcel.com/forum/e…ble-rows.html#post3412653

  • Re: Counting and suming number of visible rows


    Hello again,


    I tried the code below to count the visible the rows, but it always returns Totalrows =1, which is incorrect.


    Code
    Totalrows = ch1.Range("D:D").SpecialCells(xlCellTypeVisible).End(xlUp).count


    Also,


    I tried for the formula, Prob = "Subtotal sum of column D" / "The number of visible cells".


    Code
    Prob = WorksheetFunction.Subtotal(101, ch1.Range("D:D")) / ch1.Range("D:D").SpecialCells(xlCellTypeVisible).End(xlUp).count


    This that the correct syntax for the subtotal?


    Thanks

  • Re: Counting and suming number of visible rows


    holland1,


    Please don't bump threads after only 15 minutes.... we can all see your question.... and someone will respond. Only bump if several hours have gone by.

    Where there is a will there are many ways. Finding one that works for you is the challenge!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!