Based on a question posed by @Chips Ahoy, I decided to create a UDF to find the PercentRank of the visible cells in the range.
While @Chips seems pleased with my syntax correction, I actually can't get my UDF to work correctly.
When I run the following, the two output addresses are considered identical. In my example, using the formula =VisiblePercentRank($A$2:$A$41,0.5)
, both addresses displayed in the direct window are read $A$2:$A$41
, despite the fact that lines 3 through 11 are hidden by the autofilter.
Code:
Function VisiblePercentRank(x As Range, RankVal As Double)
Debug.Print x.Address, x.Rows.SpecialCells(xlCellTypeVisible).Address
VisiblePercentRank = WorksheetFunction.PercentRank(x.Rows.SpecialCells(xlCellTypeVisible), RankVal)
End Function
Also tried to remove .Rows
:
Function VisiblePercentRank(x As Range, RankVal As Double)
Debug.Print x.Address, x.SpecialCells(xlCellTypeVisible).Address
VisiblePercentRank = WorksheetFunction.PercentRank(x.SpecialCells(xlCellTypeVisible), RankVal)
End Function
If the second conclusion is not readable $A$2,$A$12:$A$41
or am I missing something?
Using Excel / Office 2013, 64 bit on Win7, 64 bit.
BRAIN TREATMENT UPDATE
, UDF , :
?VisiblePercentRank(range("A2:A41"),0.5)
$A$2:$A$41 $A$2:$A$11,$A$39:$A$41
0.207
=VisiblePercentRank(A2:A41,0.5)
:
$A$2:$A$41 $A$2:$A$41