所以我非常熟悉为工作表事件(例如双击)引用工作表范围。但是,在这种情况下,我希望在双击行标题而不是单元格时进行引用。它仍然特定于工作表,但到目前为止我没有成功。
我有多个范围在双击时执行不同的事件,因此我使用类似于以下示例的代码:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rWatchRange As Range
Dim sWatchRange As Range
Set rWatchRange = Range("A5:A1000")
'I somehow need it to recognize if the row header is
'double clicked between row 5 and 1000 to fire off the second sub
Set sWatchRange = Range("5:1000")
If Not Application.Intersect(Target, rWatchRange) Is Nothing Then
Run "aFormattingSub"
End If
If Not Application.Intersect(Target, sWatchRange) Is Nothing Then
Run "aSubToInsertNewLineAndGroupWithRowAbove"
End If
End Sub
Run Code Online (Sandbox Code Playgroud)
我不确定 Excel 中是否有工作表参考、应用程序参考或我所知道的可以执行此操作的设置。