Let's say I want to click in a certain sheet of an excel file on cells:
- A1 - 3 times
- A2 - 5 times
- B1 - 10 times
- B2 - 20 times
I'd like the output to show the number of clicks in each cell, as I am clicking them (https://i.stack.imgur.com/1KfHT.png). How can I obtain this? I've been trying many variants of the code below, without success.
Many thanks!
Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each cell In Range("A1:B2")
xNum = 0
On Error Resume Next
Set myRange = cell
If cell Is Nothing Then Exit Sub
If Intersect(myRange, Target) Is Nothing Then Exit Sub
xNum = xNum + 1
MyRange.Value = xNum
Next cell
End Sub