vba 选择工作表时转到特定单元格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42251900/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
go to specific cell when a worksheet is selected
提问by Mansour
I want to go to specific cell when a worksheet is selected
我想在选择工作表时转到特定单元格
Private Sub Worksheet_Cellselection()
ActiveSheet Goto:="D5"
End Sub
That one does not work
那个不行
回答by Shai Rado
You need to use the Worksheet_Activate
event of the relevant worksheet:
您需要使用Worksheet_Activate
相关工作表的事件:
Private Sub Worksheet_Activate()
Range("D5").Select
End Sub
To use for several worksheets in a Workbook, move the code to Workbook_SheetActivate
evenrt (inside the Workbook
level):
要用于工作簿中的多个工作表,请将代码移动到Workbook_SheetActivate
eventrt(在Workbook
关卡内):
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Select Case Sh.Name
Case "Sheet1", "Sheet2", "Sheet4" '<-- run it only for sheet's with these names
Range("D5").Select
End Select
End Sub
回答by Diego Ribba
Application.Goto ActiveSheet.Range("D5")