Skip to Content
Former Member
Mar 31, 2015 at 12:30 PM

AAO- macro to compare two cell data and display a pop up message when one exceeds the other.


Hi Experts ,

I have tried an approach in AAO , in which i am comparing two cell data using a MAcro and displaying the error message when one of the cell value exceeds the other.

Let suppose i have two cells in my AAO that is displayed as part of a query displayed in the layout.

C1 and C2 .

Now i want an error message to be displayed for the user whenever he tries to enter any value in C1 that is less than the value in C2.

Means , at the time of saving the data , i need a check to be introduced in form of a message box that disables the user to save data.

if i enter 10000 in C1 and there is 20000 in C2 already, then the user gets a message stating "Error".

i tried the following code myself :

Sub Macro2

If Range("C1").value < Range("C2").value then

msgbox ( "Error")


End sub

But for this i have to either create a button to call the macro or just run it everytime.

Is there any way where as soon as user enters value the comparison is done and the pop up appears?

Any reply will be highly appreciated.

Thanks ,