Home » excel » Capturing the Click event in an Excel spreadsheet

Capturing the Click event in an Excel spreadsheet

Posted by: admin May 14, 2020 Leave a comment

Questions:

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.

How to&Answers:

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

Answer:

Use the Worksheet.SelectionChange event to trap this.

Answer:

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