The VLOOKUP part of the formula is not right. The second element in a VLOOKUP should be a range of cells. I suggest you upload the workbook and add some manually calculated result examples with a note as to how you calculate the result. No doubt we can then advise the correct formula.