Count # of Times Cell is Activated

jamesmev

Board Regular
Joined
Apr 9, 2015
Messages
233
Office Version
  1. 365
Platform
  1. Windows
I currently have a workbook that is locked where users can tab through and enter data.
I am trying to get a count every time Cell G5 is activated (either through tabbing or clicking).
I currently am using this code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("$G$5")) Is Nothing Then
Cancel = True
Range("Q5").Value = Val(Range("Q5").Value) + 1
End If
End Sub

However this only counts a double click. I am unable to adjust for my needs.

Any help with this?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
your are using the wrong event you should be using the worksheet selection change event which will catch both, try this:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("$G$5")) Is Nothing Then
Range("Q5").Value = Val(Range("Q5").Value) + 1
End If


End Sub
 
Last edited:
Upvote 0
your are using the wrong event you should be using the worksheet selection change event which will catch both, try this:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("$G$5")) Is Nothing Then
Range("Q5").Value = Val(Range("Q5").Value) + 1
End If


End Sub


Perfect.
Thank you!
 
Upvote 0

Forum statistics

Threads
1,223,983
Messages
6,175,778
Members
452,668
Latest member
mrider123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top