Search notes:

Catching Excel Events with VBA

Changes on a worksheet

The following sub is called when the user changes a value on a worksheet. If the changed value is in the second column, the code changes the color of the cell left to it to a specific color.
The code for the sub must be placed into the Visual Basic component belonging to the worksheet rather than into a specific code module.
private sub worksheet_change(byVal cell as range)
 '
 '  Check if user changed value in 2nd column:
    if cell.column = 2 then
     '
     ' Change cell's color one to the left
     '
       cell.offset(0, -1).interior.color = rgb(200, 130, 30)
    end if
    
end sub
Github repository about-MS-Office-object-model, path: /Excel/events/Worksheet/change.bas

Change of a selection

The event handler worksheet_selectionChange(byVal rng as range) is invoked when the selected set of cells changes on a worksheet.
Such a change takes place if a user
A use case for such an event handler might be to show/hide comments with the selectionChange event handler.

Detecting mouse clicks

Unfortunately, it seems impossible to detect if the user clicked a cell with the mouse with Excel features only.
However, it might be possible with the WinAPI function GetAsyncKeyState, see this Stackoverflow answer

See also

This example demonstrates how the codeMOdule object is used to create a dynamic event khandler for a hyperlink on a worksheet.
VBA events

Index