VBA code to display message box

suprsnipes

Active Member
Joined
Apr 26, 2009
Messages
434
Hi,

I am using a DDE link and want to display a message box. I am using the following code sample but it doesn't display a message box automatically, by this I mean I have to select the cell and push enter, even if the cell matches the statement. I haven't used this type of function before so I appreciate the help.

Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim rng As Range
   Set rng = Range("A14")
   If Not Intersect(Target, rng) Is Nothing Then
       If rng = "M" Then
        MsgBox "Cell " & _
         rng.Address & " = M"
       End If
   End If

   Set rng = Nothing

End Sub

Can anyone recommend another method?

Regards,
suprsnipes
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try switching from:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

To:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 
Upvote 0
Hi,

Thanks for the reply.

I would like to know if it is possible to setup this type of macro where the user doesn't have to select the cell or change the cell manually to display the message box. Perhaps I have done something wrong but the cell contains a formula linked to another cell and I want the message box to be triggered when the cell contains the letter "M". The code i have used attempted so far doesn't work this way instead I have to select the cell after I push enter the message box is displayed :banghead:

The cell reference is A14.

Regards,
suprsnipes.
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,820
Members
452,946
Latest member
JoseDavid

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