VBA - MsgBox Based on Cell Value
Hello everyone,
Thank you in advance for your help.
I am a beginner with VBA in Excel.
I need to display a MsgBox based on the value of a given range of cells.
For example:
If the values in the range (A1:A41) are greater than 29.99, a MsgBox should appear with a "text X"
Please take into account that there is a formula in the range of cells that gives the result.
A big thank you to everyone
Gustavo
Thank you in advance for your help.
I am a beginner with VBA in Excel.
I need to display a MsgBox based on the value of a given range of cells.
For example:
If the values in the range (A1:A41) are greater than 29.99, a MsgBox should appear with a "text X"
Please take into account that there is a formula in the range of cells that gives the result.
A big thank you to everyone
Gustavo
3 answers
-
ModeratorHello
What have you started?
What are you stuck on?
Focus on the private sub worsheet_change(target) event
Target contains the modified cell
All you have left to do is use some if... And you're good to go
--
Best regards,
Jordane -
Contributor AmbassadorHello, when should the message appear? Upon opening the file?
You write "the displayed values are greater than 29.99": do you want to display the message only if all values are greater?-
-
Contributor Ambassador@GustavoSRPWhat causes the values to change? What do the formulas contain?
There are 41 values, you didn't specify whether you wanted to receive a message as soon as any one of the values exceeds 29.99, or if all of them should exceed that.
-
-
The values of each cell change because each cell refers to another cell that performs an addition. The cell in question calculates the average amount over 52, for example.
Cell A1 contains the following formula: =B1/52
Cell B1 contains the following formula: SUM(B2:B12)
When cell A1 exceeds 29.99, a text message must appear.
So, when one or more cells in the range (''A1:A50'') reach 30 or more, the text message is displayed.-
-
@yg_beGood question, the message should appear only once per cell and the message should indicate which cell it refers to.
-
Contributor Ambassador@GustavoSRPYou should record somewhere (in a cell somewhere) whether or not to display the message.
Since you are a beginner in VBA, I suppose you can do that.
-