工作表和单元格和范围的默认范围是多少? [英] What is the default scope of worksheets and cells and range?
问题描述
当您只输入工作表()时,ActiveWorkbook或ThisWorkbook的默认范围是什么?对于那些不了解这些区别的人来说,特别是在Excel 2013中,当您希望在切换到不同的工作簿时运行宏,这是非常重要的。
通常在标准模块中,不合格的 Worksheets()
将引用ActiveWorkbook ,除非它在 ThisWorkbook
模块,在这种情况下,它将引用包含的工作簿。
同样,不合格的 Range()$ c标准模块中的$ c>将引用ActiveSheet,但在一个表单模块中将引用相应的工作表。
不合格。 ..参考文献
-------------- -------------- -------------- -----
工作表()常规模块活动工作簿
工作表模块活动工作簿
包含工作簿
Range()或Cells()Regu lar模块活动表
表单模块包含表
ThisWorkbook活动表
方式来避免不必记住任何 ,这样做总是完全符合任何工作表
,
,范围
或细胞
参考。
When you just type worksheets() what is the default scope ActiveWorkbook or ThisWorkbook? For those who do not know these distinctions they are extremely important especially in Excel 2013 when you want macros to run when you switch to different workbooks.
Typically in a standard module an unqualified Worksheets()
will reference the ActiveWorkbook unless it's in the ThisWorkbook
module, in which case it will reference the containing workbook.
Likewise, an unqualified Range()
in a standard module will reference the ActiveSheet, but in a sheet code module will reference the corresponding worksheet.
Unqualified... Where References
-------------- -------------- -------------------
Worksheets() Regular module Active workbook
Sheet module Active workbook
ThisWorkbook Containing workbook
Range() or Cells() Regular module Active sheet
Sheet module Containing sheet
ThisWorkbook Active sheet
The easy way to avoid having to remember any of this is to always fully qualify any Worksheets
, Sheets
, Range
, or Cells
reference.
这篇关于工作表和单元格和范围的默认范围是多少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!