Conditional Formatting/Using conditions in VBA

ankita.sethi

Board Regular
Joined
Apr 27, 2011
Messages
58
Hi,

I am trying to build a code where some message needs to pop out when a certain condition is met.
lets say the condition is that Cells("B12").Value > 500.
This cell has a formula which is the sum of some other cells. As soon as this sum crosses 500, i need a message to pop up using msgbox.

Please help me do this.
I searched a lot and found lots of info about conditional 'formatting' but couldn't work my way around this.

Any help would be appreciated.

Regards,
Ankita
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Calculate()
If Range("B12").Value > 500 Then MsgBox "your message here", vbInformation
End Sub
 
Upvote 0
Thanks a lot!
but the problem with this is that it checks the cell value only when it runs. as in, if the value in the cell is already greater than 500 at the time of running the code, then only it will pop up the message. i want the code to be such that when it runs, it should put some condition in the cell so that message pops up if the value exceeds 500 even later. (like how conditional formatting works...its not just an if condition there...whenever the given condition meets, the format changes).
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

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