Is there a way of counting mouse clicks on an active XL cell and displaying the real time count in the cell, in essence giving a click count?
Or in the case of a handheld, tapping an active cell and having the value incrementally increase with each tap...
Count Mouse Clicks On Cell
-
-
Re: Count Mouse Clicks On Cell
Code
Display MorePrivate Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("B4")) Is Nothing Then If IsNumeric(Range("B4").Value) Then Range("B4").Value = Range("B4").Value + 1 Else Range("B4").Value = 1 End If End If End Sub
In Excel 2000 this is the only option that comes near. Don't know if a click event has been added to the Worksheet events. If there is you can use the same code in it.
Erik
-
Re: Count Mouse Clicks On Cell
Winte is a good solution but once you click the cell it wont count the clicks untill you have clicked another cell.
If this is a problem you could perhaps consider using the before right click event:
CodePrivate Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean) If Not Intersect(Target, Range("B4")) Is Nothing Then If IsNumeric(Range("B4").Value) Then Range("B4").Value = Range("B4").Value + 1 Else Range("B4").Value = 1 End If End If Cancel = True End Sub
Or even the before double click event? just throwing in some more options for you.
-
Re: Count Mouse Clicks On Cell
What about left click? Or is the buttons are reversesd ie right = left etc
Been looking at this one not sure of a fix, intresting thou :~0jiuk
-
Re: Count Mouse Clicks On Cell
Maybe you could switch the buttons when clicking on the cell to harness the before right click then switch them back when you click another cell??
Bit out of my level - as you say though Jack interesting idea.
-
-
Re: Count Mouse Clicks On Cell
Yeah Jack was playing with switching but waht is needed is capture in VBA a not so easy - intresting
jiuk
-
Re: Count Mouse Clicks On Cell
Don't know the overall requirements of the request BUT you CAN DO this
via some API's and, as you have suggested swapping the mouse + Event codeNote: It needs the AddressOf operator so will only work in Xl2000+
This example Monitors a range = C2:C20 ..... No real testing done.
You need to Start the timer to monitor the Range ....
This is just ONE way to do it ... NO Real testing....
-
Re: Count Mouse Clicks On Cell
QuoteOr in the case of a handheld, tapping an active cell and having the value incrementally increase with each tap...
Don't think Handhelds support any coding.
-
Re: Count Mouse Clicks On Cell
Hi,
I've tried several events :
Before right click -> Normally left click is used to select a cell
Before doubbleclick -> Directs to the contents of the cell, selection change required to leave the contentsCode
Display MorePrivate Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("B4")) Is Nothing Then If IsNumeric(Range("B4").Value) Then Range("B4").Value = Range("B4").Value + 1 Selection.Offset(1, 0).Select Else Range("B4").Value = 1 Selection.Offset(1, 0).Select End If End If End Sub
Adding a selection change completes it.
Erik
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!