Question

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.

Was it helpful?

Solution

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

OTHER TIPS

Use the Worksheet.SelectionChange event to trap this.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top