Where did you put the first code.. was it within range A1:Y10?

If not, it should work too, but don't think that is what you want anyways.