好吧,所以我在这方面是全新的。新的工作角色。我收到了这个excel请求:
这就是我所拥有的......
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Sheets.Add
End Sub
另外,请原谅我,如果我违反任何规则,这是我第一次在这里发帖。非常感谢你的帮助!
答案 0 :(得分:3)
您正走在正确的道路上,只需要更多的组件。关键点是声明和使用对象变量(在这种情况下为ws
)
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim ws As Worksheet
' Prevent screen flicker
Application.ScreenUpdating = False
' Add worksheet
Set ws = Me.Parent.Worksheets.Add
' Add Hyperlink
Target.Hyperlinks.Add Anchor:=Target, Address:="", SubAddress:=ws.Cells(1, 1).Address(True, True, , True), TextToDisplay:=ws.Name & "!A1"
' Restore original sheet as active
Me.Activate
' Disable original Doubleclick action
Cancel = True
' Restore screen updating
Application.ScreenUpdating = True
End Sub