views:

397

answers:

3

How can I capture the event in Excel when a user clicks on a cell. I want to be able to use this event to trigger some code to count how many times the user clicks on several different cells in a column.

+1  A: 

Use the Worksheet.SelectionChange event to trap this.

Ben Hoffstein
+2  A: 

Check out the Worksheet_SelectionChange event. In that event you could use Intersect() with named ranges to figure out if a specific range were clicked.

Here's some code that might help you get started.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    If Not Intersect(Target, Range("SomeNamedRange")) Is Nothing Then
         'Your counting code 
    End If
End Sub
Robert S.
A: 

Worksheet SelectionChange event would do it. Note that this fires every time user clicks a new cell.

Andrew Cowenhoven