vba 宏:如何在工作簿中选择多个工作表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3274660/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 11:53:37  来源:igfitidea点击:

Macro: how can I select multiple sheets in a workbook?

excelvba

提问by RocketGoal

The workbook has over 50 worksheets and I'm working through an old macro that will help me amend the same range within each sheet. Howvere they have ahrdcoded the sheets.selectstatement.

该工作簿有 50 多个工作表,我正在处理一个旧的宏,它将帮助我修改每个工作表中的相同范围。然而,他们已经对sheets.select声明进行了编码。

How do you write: Sheets(Array("Sheet1", "Bob", "1953", etc, etc, etc)).Selectso that all the sheets are selected - from first to last, no matter what name someone has given them?

你怎么写:Sheets(Array("Sheet1", "Bob", "1953", etc, etc, etc)).Select这样所有的工作表都会被选中——从头到尾,不管别人给它们起什么名字?

Many thanks

非常感谢

Mike

麦克风

回答by Lunatik

ThisWorkbook.Sheets.Select

ThisWorkbook.Sheets.Select

回答by hjindal

above method works for selecting all sheets in the workbook.

上述方法适用于选择工作簿中的所有工作表。

What if we have to selectively make the selections on Sheet?

如果我们必须有选择地在 Sheet 上进行选择怎么办?