Hello all.
I need to force the entry in a cell to be within a certain range of values depending on the input in another cell
NOTE: I cannot use validation since I have already used validation to restrict the cell in a different way already. Hence my thought that a macro is the way to go.
Basically I want
- USER to enter a value in cell X
- Macro to check if a results cell exceeds a value
-- IF not then the cell X accepts the user input
-- IF so then excel MUST flash a message saying
- 1) "you cannot do that..." or something to that effect and
- 2) make sure the values is restored to default
I have managed to do 1) above with the code below BUT I need to accomplish 2). THanks.
****** CURRENT CODE WHICH DOES 1) ABOVE*******
Private Sub Worksheet_Calculate()
If Me.Range("b75").Value >= Me.Range("b76").Value Then MsgBox "Adjust X to Y"
If Me.Range("c75").Value >= Me.Range("c76").Value Then MsgBox "Adjust A to B"
End Sub
I need to force the entry in a cell to be within a certain range of values depending on the input in another cell
NOTE: I cannot use validation since I have already used validation to restrict the cell in a different way already. Hence my thought that a macro is the way to go.
Basically I want
- USER to enter a value in cell X
- Macro to check if a results cell exceeds a value
-- IF not then the cell X accepts the user input
-- IF so then excel MUST flash a message saying
- 1) "you cannot do that..." or something to that effect and
- 2) make sure the values is restored to default
I have managed to do 1) above with the code below BUT I need to accomplish 2). THanks.
****** CURRENT CODE WHICH DOES 1) ABOVE*******
Private Sub Worksheet_Calculate()
If Me.Range("b75").Value >= Me.Range("b76").Value Then MsgBox "Adjust X to Y"
If Me.Range("c75").Value >= Me.Range("c76").Value Then MsgBox "Adjust A to B"
End Sub