vba 将工作表传递给子程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2376132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Passing a Worksheet to a subroutine
提问by Blade3
I have the following code:
我有以下代码:
Private Sub SortWorksheet(ByVal sheet As Worksheet)
Dim sStartColumn
Dim iTopRow
Dim sEndColumn
Dim iBottomRow
Dim Rng As Range
Dim sRange1 As String
.
.
.
and I am calling the function like so:
我像这样调用函数:
SortWorksheet (DestSheet)
I am getting a runtime error on the above line saying "Object doesn't support this property or method"
我在上面的行中收到运行时错误,提示“对象不支持此属性或方法”
DestSheet is a worksheet variable.
DestSheet 是一个工作表变量。
Why is this code not working?
为什么这段代码不起作用?
回答by Blade3
Disregard, apparently in VBA the subroutine has be called like this
无视,显然在 VBA 中,子程序是这样调用的
SortWorksheet DestSheet
Hey, I'm a C/C++/C# guy! :)
嘿,我是一个 C/C++/C# 人!:)