Sheets.Select和Sheets.Activate有什么区别? [英] What is the difference between Sheets.Select and Sheets.Activate?

查看:1683
本文介绍了Sheets.Select和Sheets.Activate有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VBA for Excel中, Sheets.Select Sheets.Activate

In VBA for Excel, what is the difference between Sheets.Select and Sheets.Activate ?

推荐答案

区别在于灵活性。

激活使指定的工作表成为活动工作表,并且只能应用于单个工作表

Activate make the specified sheet the active sheet, and may only be applied to a single sheet

选择允许选择扩展当前所选的工作表以包括指定的工作表,例如

Select allow for optionally extending the currently selected sheets to include the specified sheet, eg

Worksheets("Sheet2").Select Replace:=False

,并允许选择一张表格数组

and also allow for selecting an array of sheets

Sheets(Array("Sheet3", "Sheet2")).Select






以最小的形式选择激活做同样的事情。

例如,如果当前仅选择一张表(如 Sheet3 ),或者如果选择了多张表格但是不包括 Sheet2 ,然后 Worksheets(Sheet2)。选择工作表(Sheet2)。激活均使 Sheet2 唯一选择和活动的工作表。

For example, if only one sheet is currently selected (say Sheet3) or if more than one sheet is selected but excluding say Sheet2, then Worksheets("Sheet2").Select and Worksheets("Sheet2").Activate both make Sheet2 the sole selected and active sheet.

另一方面,如果同时选择 Sheet2 Sheet3 Sheet2 是活动工作表,然后是工作表(Sheet3)。激活选中两个工作表,使 Sheet3 活动工作表,而工作表(Sheet2)。选择使 Sheet3 唯一选择和活动的工作表。

On the other hand, if say both Sheet2 and Sheet3 are selected and Sheet2 is the active sheet, then Worksheets("Sheet3").Activate leaves both sheets selected and makes Sheet3 the active sheet, whereas Worksheets("Sheet2").Select makes Sheet3 the sole selected and active sheet.

这篇关于Sheets.Select和Sheets.Activate有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆