ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Counting Hidden Rows (https://www.excelbanter.com/excel-discussion-misc-queries/154403-counting-hidden-rows.html)

Covington

Counting Hidden Rows
 
Is there a way in Excel where I can count rows and columns and get a number
that excludes any hidden rows or columns? Thanks.

Dave Peterson

Counting Hidden Rows
 
In a subroutine/macro?

For a single area range, you can get the number of visible rows/columns with
something like:

Option Explicit
Sub testme()
Dim myRng As Range
Dim myVisibleCell As Range
Set myRng = ActiveSheet.Range("a1:x99")

Set myVisibleCell = Nothing
On Error Resume Next
Set myVisibleCell = myRng.Cells.SpecialCells(xlCellTypeVisible).Cells( 1)
On Error Resume Next

If myVisibleCell Is Nothing Then
MsgBox "0 visible rows and 0 visible columns!"
Else
MsgBox "Visible Rows: " _
& Intersect(myVisibleCell.EntireColumn, myRng) _
.Cells.SpecialCells(xlCellTypeVisible).Cells.Count _
& vbLf & _
"Visible Cols: " _
& Intersect(myVisibleCell.EntireRow, myRng) _
.Cells.SpecialCells(xlCellTypeVisible).Cells.Count
End If
End Sub

Covington wrote:

Is there a way in Excel where I can count rows and columns and get a number
that excludes any hidden rows or columns? Thanks.


--

Dave Peterson


All times are GMT +1. The time now is 08:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com