Need VBA macro code to reset value to default if outside validation range

kankudan

New Member
Joined
Jan 23, 2012
Messages
2
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
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,226,735
Messages
6,192,732
Members
453,752
Latest member
Austin2222

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top