SpecialCells(xlCellTypeVisible) also includes hidden/filtered cells

前端 未结 1 1023
后悔当初
后悔当初 2021-01-24 19:23

I have a dataset that I\'m using a filter on. I simply want to calculate the total values in column N, that are visible. The data starts in row 2, and ends at row 2047.

<
1条回答
  •  醉梦人生
    2021-01-24 19:53

    Try setting your rng with the line below:

    Set rng = Range("N2:N" & Cells(Rows.Count, "N").End(xlUp).Row).SpecialCells(xlCellTypeVisible)
    

    Later using your debug line Debug.Print rng.Address, I get the following range in the immediate window:

    $N$901:$N$937
    

    0 讨论(0)
提交回复
热议问题