COUNTVISIBLE

COUNTVISIBLE(rgeValues)
Returns the number of visible, non blank cells in a range.

rgeValues

REMARKS
* This function excludes hidden cells caused by AutoFilter, Grouping or that have been Manually Hidden.
* You can use the built-in COUNT function to include hidden cells.
* You can use the add-in COUNTVISIBLEIFS function to
* You can use the add-in AVERAGEVISIBLE function to
* You can use the add-in MAXVISIBLE function to
* You can use the add-in MINVISIBLE function to
* You can use the add-in SUMVISIBLE function to
* You can use the user defined COUNTVISIBLEA function to
* You can use the user defined MEDIANVISIBLE function to

 A
1??

Public Function COUNTVISIBLE( _ 
         ByVal rgeValues As Range) _
         As Integer
Dim rgeCell As Range
Dim ltotalcells As Long
   Application.Volatile
   For Each rgeCell In rgeValues
      If (rgeCell.EntireRow.Hidden = False) And _
         (rgeCell.EntireColumn.Hidden = False) Then
         
         If (Len(rgeCell.Value) > 0) Then
            If (rgeCell.Value <> "True") And _
               (rgeCell.Value <> "False") And _
               (Application.WorksheetFunction.IsText(rgeCell.Value) <> True) Then
               ltotalcells = ltotalcells + 1
            End If
         End If
      End If
   Next rgeCell
   COUNTVISIBLE = ltotalcells
End Function

Public Function COUNTVISIBLE2( _
         ByVal rgeValues As Range) _
         As Integer
Dim ltotalcells As Integer
   ltotalcells = Application.WorksheetFunction.Aggregate(2, 5, rgeValues)
   COUNTVISIBLE2 = ltotalcells
End Function

© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext