Creating a counter in VBA
问题 I wanted to know if there is an effective way to create a counting mechanism on vba using a Worksheet_SelectionChange event? I want to count how many times a specific cell is selected. If the cell is selected then the variable will go up by one, otherwise no change is made to the variable. Dim S As String Dim count As Integer count = 0 S = "$" & "D" & "$" & ActiveCell.Row If ActiveCell.Address = S Then count = count + 1 Else count = count End If 回答1: This should work for you. Place this code