KoenR.
KoenR.

Reputation: 5

Create Message box, when cell is selected (excel)

Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.Address = "$B$1" Then
       MsgBox "Something"
   End If
End Sub

Hello, I have a problem with a macro, I want to create a pop-up message when somebody clicks on B1. This Macro for some reason does'nt do anything, it's probably something simple/stupid, anybody has any idea's?

Upvotes: 0

Views: 8008

Answers (1)

Gareth
Gareth

Reputation: 5243

You're using the wrong Worksheet event. You need to use the Worksheet_SelectionChange event like so:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Address = "$B$1" Then
        MsgBox "Something"
    End If

End Sub

Make sure you place this in the sheets module that you wish it to fire from.

Upvotes: 4

Related Questions