works correctly for me
by correctly, i meant the sum showed in the cell, not the formula

i just pasted your code into my ide and set a range to suit