Worksheet_Change: Conditionally keeping previously entered value
Posted by Bjorn Skogseth on May 15, 2001 11:36 AM
Let's say that I want to restrict the value in cell A2 so that it cannot be higher than the value in A1. (And the same for B2 and B1, and so on - note that A1, B1, etc can have different values.)
I can do this by using the Worksheet_Change event and testing whether the newly entered value in A2 is outside the allowed range, ie. higher than A1. However, how do I keep the previously entered value in A2 in that case? I don't want to set A2=A1 (that's what I'm doing now), it would be better to keep the old value.
The Target As Range variable doesn't seem to contain any information on what the previous value in the changed cell was. Anyone know?