stPrice(i) + jelsek > TotQtym = TotQty - (k - Qty(i))j =[[m * costprice(i)] + jend ifwendAvgPrice = j/TotQtyNOTEI want to do the valuation and then get the Average price (AvgPrice) as at the selected date.Which is the array vakue divided by TotQtyAvgPrice = j/TotQtyTotQty = Balance as at dateJ is the value for the arrayquote:Originally posteod by visakh16hmm...your posted code is a bit confusing.