Zend certified PHP/Magento developer

Which function to use for adding and multiplying cells?

I need to add up and multiply some cells but only if a number in a certain cell is in range from one value to another. Can somebody help me which function do I need to use and how?

Here is what I need.

lets say that i need to do this (E12-D20)*C22 but only if the value in cell E12 is larger than 370483 and less or same than 1004160.