The problem with your code, aside from that it has no code tags, is that Excel sees no dependency on the range from which the result is computed, so changing the range will not cause the function to recalculate.