Hi,

Try this in B1 copied down

=IF(IF(A1=0,"",ROW())="","",IF(A1=0,"",ROW())*1-COUNTIF($A$1:A1,0))