To rank from highest to lowest visible cells that are the result of either an AutoFilter or manually hidden rows, assuming that A2:A100 contains the data, try...
B2, confirmed with CONTROL+SHIFT+ENTER, and copy down:
=SUM(IF(SUBTOTAL(103,OFFSET($A$2:$A$100,ROW($A$2:$A$100)-ROW($A$2),0,1))>0,IF(A2<$A$2:$A$100,1)))+1
Adjust the ranges accordingly. To rank from lowest to highest, replace...
A2<$A$2:$A$100
with
A2>$A$2:$A$100