You must use the SheetChangeobject method Workbook:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
'run code everytime one of the sheets is changing
End Sub
, : ( ), , ( ).
Workbook_SheetSelectionChange:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
'run code everytime one of the sheets' cells is selected
End Sub
. , , . , " " " " ( , , , : VBA [ Range("A1").Select], /// ). , , , .
( ?), API user32.dll :
Private Declare PtrSafe Function GetAsyncKeyState Lib "user32.dll" (ByVal vKey As Long) As Integer
. PtrSafe API 64- . 32-, API.
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Dim check As Boolean
check = GetAsyncKeyState(1) '<-- True if click, False if not click
If check Then '<
'run code everytime one of the sheets' cells is selected and you intercept a click
End If
End Sub
. , , , . , , 95% , , .
, 100% SelectionChange ( ), , ( ):
Sub test()
Dim r As Range
r = Cells.SpecialCells(xlCellTypeVisible)
End Sub
- , SelectionChange ( ).