Looking to return the first instance and the smaller of two values inside a loop, while referencing some named ranges.

=MIN(D2,(INDEX(POData_RecdQty,SMALL(IF(POData_CatNum=$B2,ROW(POData_CatNum)-ROW(INDEX(POData_CatNum,1,1))+1),1))))

Having some trouble getting through putting this in VBA Code...