I am trying to write a simple macro to display a pop-up (vbOKOnly) if the value in a cell exceeds a certain value.
I basically have a worksheet with products and discounts. I have a formula in one cell, say A1, that shows the discount as a percent (50% or .5) effective discount of all the entries.
What I’m looking for is code to display a message box if the value of cell A1 exceeds say 50%, because the input of another cell pushed the discount over 50%.
Thanks!
You could add the following VBA code to your sheet:
Every time a cell is changed on the sheet, it will check the value of cell A1.
Notes:
Widor uses a different approach (
Worksheet_Calculateinstead ofWorksheet_Change):Conclusion: use
Worksheet_Changeif A1 only depends on data located on the same sheet, useWorksheet_Calculateif not.