Sl. No., Description, Qty, Unit, Rate, Amount, Flag are the fields of an excel sheet.

If the flag field is “tot”, then the corresponding cells above the Amount field from flag “h” to flag “tot” should be summed, else (i.e. if the flag is “s” or “m”) the amount field should be the product of rate and qty.

There will be different “h” fields in the flag based on the different headings. Hence, the items immediately up to the first “h” while searching up from “tot” flag should only be included in the total.

What is the formula to be used in Amount column for this to be entered in Amount column?

image of sample file is attached here http://s000.tinyupload.com/?file_id=...21600677011075

Excel file is attached here http://s000.tinyupload.com/?file_id=...65366415914068