# Index Aggregate formula. Need expert help.

I hope someone can help me out with this.. The formula (listed below)works great in Excel but in Calc I get $Div/0! Errors. I think the problem is with the "aggregate" portion. Here is the formula: =IF(ROWS($AH$4:AH4)<=$AH$3,INDEX($S$4:$S$16,AGGREGATE(15,3,($R$4:$R$16=$AI$3)/($R$4:$R$16=$AI$3)*(ROW($R$4:$R$16)-ROW($R$3)),ROWS($AH\$4:AH4))),"")