X=HIGH(0,X) will force X up to 0 if it's too low. X=LOW(50,X) will force X down to 50 if it's too high. X=BOUNDS(X,0,50) will force X to stay within the bounds of 0-50 by forcing it up to zero if it's too low or down to 50 if it's too high.