【发布时间】:2017-08-12 03:56:05
【问题描述】:
试图从模块中获取子组件以在另一个工作表中运行。从某种意义上说,停止使用冗余范围并保持其精简。
i.e.
-Module object-
Public sub method1()
{
Range("B4:B23") = ""
Range("C4:C23") = ""
'Empties these ranges...
}
-worksheet(s)-
sub project)
{
with sheet1 (or on any sheet 2,3,4,5... etc.)
Call module1.method1
'but this method only works on the module object, not in the context of the 'specified worksheet where it is needed
End with
理想情况下,通过在任何工作表中使用方法 1 来清除范围内的数据。我尝试的每个引用都只是运行 module1 方法而没有任何效果,或者对方法或工作表进行无用的引用。只是试图通过不写对格式相同的每个工作表的直接引用来节省代码空间。
【问题讨论】:
-
只需录制一个宏并调整代码以使其可重用