Based on the question posed by @Chips Ahoy, I decided to create a UDF to find the PercentRank of visible cells in a range.
While @Chips seems happy with my syntax co
It seems that SpecialCells
is known to fail in UDFs. A few sources: 1, 2, 3
You'd have to create your own function. Perhaps something like this:
Function VisiblePercentRank(x As Range, RankVal As Double)
Debug.Print x.Address, VisibleCells(x).Address
VisiblePercentRank = WorksheetFunction.PercentRank(VisibleCells(x), RankVal)
End Function
Private Function VisibleCells(rng As Range) As Range
Dim r As Range
For Each r In rng
If r.EntireRow.Hidden = False Then
If VisibleCells Is Nothing Then
Set VisibleCells = r
Else
Set VisibleCells = Union(VisibleCells, r)
End If
End If
Next r
End Function