Execute a macro by selecting a cell

C

Chip Pearson

You can use the SelectionChange event procedure to trap the event raised
when the user selects a cell. For example, put the following code in the
appropriate sheet's code module, and it will run code when a user selects a
single cell in the range A1:A10

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then
Exit Sub
End If
If Not Application.Intersect(Range("A1:A10"), Target) Is Nothing Then
MsgBox "You selected: " & Target.Address
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top