ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting Clicks (https://www.excelbanter.com/excel-programming/366690-counting-clicks.html)

[email protected]

Counting Clicks
 
This may be a trivial problem, but it has me slightly bugged. Is it
possible to count the number of times an Excel cell has been clicked
on?

What I have in mind is, for example, an array of cells from A1 to I10,
and a corresponding array from A11 to I21.

The idea is that if a cell in the upper array is clicked, the
corresponding cell in the lower array is increased by one. Thus if C3
is clicked, C13 would by incremented.

Is such a thing possible and if so, how?


RB Smissaert

Counting Clicks
 
Unless you look at the actual mouse-clicks with the
Windows API, this is the best I can come up with:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim lScrollRow As Long
Dim lScrollColumn As Long
Dim lTargetRow As Long
Dim lTargetColumn As Long

If Target.Row 10 Or Target.Column 10 Then
Exit Sub
End If

Application.ScreenUpdating = False

lScrollRow = ActiveWindow.ScrollRow
lScrollColumn = ActiveWindow.ScrollColumn

lTargetRow = Target.Row
lTargetColumn = Target.Column

Cells(lTargetRow + 10, lTargetColumn) = _
Cells(lTargetRow + 10, lTargetColumn) + 1

Cells(65536, 256).Select

ActiveWindow.ScrollRow = lScrollRow
ActiveWindow.ScrollColumn = lScrollColumn

Application.ScreenUpdating = True

End Sub

Put this in the worksheet code.
It will be simpler if you could do it with a right mouse-click as there is
the
Worksheet_BeforeRightClick event.


RBS

wrote in message
...
This may be a trivial problem, but it has me slightly bugged. Is it
possible to count the number of times an Excel cell has been clicked
on?

What I have in mind is, for example, an array of cells from A1 to I10,
and a corresponding array from A11 to I21.

The idea is that if a cell in the upper array is clicked, the
corresponding cell in the lower array is increased by one. Thus if C3
is clicked, C13 would by incremented.

Is such a thing possible and if so, how?



[email protected]

Counting Clicks
 
On Sun, 9 Jul 2006 17:09:40 +0100, "RB Smissaert"
wrote:

Unless you look at the actual mouse-clicks with the
Windows API, this is the best I can come up with:

Rest snipped



Thanks very much. I'll give it a try



All times are GMT +1. The time now is 03:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com