I need some help creating the Excel VBA to display a message box when a any input range to a calculated cell (cell with a formula in it) changes and meets a given criterion for the range.
For example, the range "B2" contains calculated cells which are a function of "A2", and if, upon updating the input, "A2", the recalculated cell, "B2" exceeds 20%, I want to warn the user with a message box.
Edit: Scott reminded me of the
Intersect
function which works out nicer than thisInRange
functionEdit2: This will allow you to have different rules for different ranges. If the cell which was changed by the user is within one of your controlled ranges then the validation rule for that range is called. Otherwise the function goes on.
Here is an example of using the workbook sheet change event that is checking for a change in the A1 cell in sheet 1
UPDATE
This code will only trigger if your input cells change, which is better than just using 'Worksheet_Calulate`: