Sheets.Select和Sheets.Activate有什么区别? [英] What is the difference between Sheets.Select and 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屋!