I am stuck up at work and need someone's help. Actually I have a huge table of some conditions like:

55x(x-1)(x-2)(x+3)(x+4)

55x(x-1)(x-2)(x-2)(x-2)(x-2)

55x5555x

55xx(x+1)(x+1)(x+2)(x+2)

55xx(x-1)(x-1)(x-2)(x-2)

55xy(x+1)y(x+2)y

55xy55xy

55xyx(y+1)x(y+2)

55xyx(y-1)x(y-2)

My objective is to

- replace Xs and Ys one by one from 0 to 9 and
- when it says "x-1" or (y+1) sort of things, I need to calculate them as well.

The important thing is that I need ONE formula to work on all rows.