Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的工作簿中有大约 8 张不同名称的工作表。有没有办法使用 VBA 根据它们的索引号激活这些工作表中的一个或多个?例如,我有名为“月份”、“姓名”、“年龄”等的工作表……我怎样才能找到它们的索引号?
尝试这个
Sheets("<sheet Name>").Index
如果你想获得代号
Sheets("<sheet Name>").codename
工作表名称可能与代码名称不同。创建工作表时,工作表名称和代码名称相同,但更改工作表名称不会更改代码名称,更改代码名称(使用 Visual Basic 编辑器中的“属性”窗口)不会更改工作表名称。
要获取工作表的索引: sheets("month").index
sheets("month").index
按索引激活: sheets(5).activate
sheets(5).activate