Zend certified PHP/Magento developer

Summing cells in a row up to a given column number

This has been puzzling me and I hope you lot can help me out.

I have a table of numbers, and I wish to sum all the values in a row up to a specified column number. Idea being I can change the ‘sum up to number’ and the sum total will automatically update to the given range.
Below is a simplified sheet of what I am aiming for.
I can do it manually on this example but my live sheet is bigger so having a simple formula would be much easier.
the aim I have in mind

I have had success at doing it with a load of if statements however this clearly isn’t the most efficient method see below:

Using if Statements

Thank you in advance, really appreciate any advice you give.

Jasper