• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VB Macro - Msgbox( )

manoj_th

Member
How to get a Msgbox() automatically(without shortcut / command button) when a value gets changed in a particular cell. eg: If the value in the Cell A3 is >= 100, A message box should appear.
 
Hi, manoj_th!

Just add this VBA code to the worksheet involved in the VBAProject (Alt-F11).

-----

Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$C$3" Then

If Target.Value >= 100 Then

DoEvents

MsgBox "Value in A3>=100: " & CStr(Target.Value), _

vbApplicationModal + vbOKOnly, "Alert"

End If

End If

End Sub

-----

Regards!
 
SirJB7

I have added this code in a module under the active worksheet. But I get no message box when I enter values in A3 greater than 100.

please help.

Thanks.
 
Hi Manoj,


please review the code provided to you, the target is set to catch and check the value for only Cell C3, and not A3. You need to refine the requirement whether to check for certain cells, or for entire sheet.


Regards,

Prasad DN
 
Sir,

I tried several times, even though it's not working. Showing error at "DoEvents"

line.


Pls help in this regard.


Thanking you,

Manoj
 
heh. prasaadn is having a little fun with you:


If Target.Address = "$C$3" Then....

MsgBox "Value in A3>=100: " & CStr(Target.Value), _


What error is it throwing at DoEvents?
 
Back
Top