How to count total clicks in a specified cell in Excel?
This article is talking about counting total clicks in a specified cell in Excel.
Please do as follows to count total clicks in a specified cell in Excel.
1. In the worksheet contains the cell you need to count its total clicks, right-click the sheet tab, and then click View Code from the context menu.
2. In the Microsoft Visual Basic for Applications window, please copy and paste below VBA code into the Code window.
VBA code: Count total clicks in a specified cell in Excel
Public xRgS, xRgD As Range Public xNum As Long Private Sub Worksheet_SelectionChange(ByVal Target As Range) On Error Resume Next If Target.Cells.Count > 1 Then Exit Sub Set xRgS = Range("E2") If xRgS Is Nothing Then Exit Sub Set xRgD = Range("H2") If xRgD Is Nothing Then Exit Sub If Intersect(xRgS, Target) Is Nothing Then Exit Sub xNum = xNum + 1 xRgD.Value = xNum End Sub
Note: In the code, E2 is the cell you need to count its total clicks, and H2 is the output cell of the counting. Please change them as you need.
3. Press the Alt + Q keys to close the Microsoft Visual Basic for Applications window.
From now on, when clicking on cell E2 in this specified worksheet, the total clicks will be auto-populated in cell H2 as below screenshot shown. For example, if you click on the cell E2 5 times, number 5 will be displayed in cell H2.
Best Office Productivity Tools
Supports Office/Excel 2007-2021 and 365 | Available in 44 Languages | Easy to Uninstall Completely
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need Is Just A Click Away...
Supercharge Your Excel Skills: Experience Efficiency Like Never Before with Kutools for Excel (Full-Featured 30-Day Free Trial)
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day! (Full-Featured 30-Day Free Trial)