vba 'workbooks.worksheets.activate' 有效,但 '.select' 无效
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17410434/
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
'workbooks.worksheets.activate' works, but '.select' does not
提问by user2495069
Could anyone tell me why, when I refer to a particular sheet, I could use:
谁能告诉我为什么,当我提到一个特定的工作表时,我可以使用:
workbooks("A").worksheets("B").activate
but not
但不是
workbooks("A").worksheets("B").select
?
?
回答by Tim Williams
You can't select a sheet in a non-active workbook.
您不能在非活动工作簿中选择工作表。
You must first activate the workbook, then you can select the sheet.
您必须先激活工作簿,然后才能选择工作表。
workbooks("A").activate
workbooks("A").worksheets("B").select
When you use Activate it automatically activates the workbook.
当您使用“激活”时,它会自动激活工作簿。
Note you can select >1 sheet in a workbook:
请注意,您可以在工作簿中选择 >1 个工作表:
activeworkbook.sheets(array("sheet1","sheet3")).select
activeworkbook.sheets(array("sheet1","sheet3")).select
but only one sheet can be Active, and if you activate a sheet which is not part of a multi-sheet selection then those other sheets will become un-selected.
但只有一个工作表可以是活动的,如果您激活一个不属于多工作表选择的工作表,那么其他工作表将被取消选中。