我试图通过传递某个工作表名称作为参数来调用子例程,但收到以下错误:
Object doesn't support this property or method
这是我的代码:
Public Sub PerformanceLeague()
Dim wsPerformanceLeague As Worksheet
Set wsPerformanceLeague = Worksheets("PerformanceLeague")
SetHeadings wsPerformanceLeague
End Sub
Public Sub SetHeadings(sSheet As Worksheet)
Dim headers() As Variant
Dim ws As Worksheet
Dim wb As Workbook
Application.ScreenUpdating = False
End Sub
我也尝试按如下方式调用子例程,但收到相同的错误:
Call SetHeadings(wsPerformanceLeague)
最佳答案
声明
wsPerformanceLeague
作为工作表。Dim wsPerformanceLeague as Worksheet
更改
wsPerformanceLeague = Worksheets("PerformanceLeague")
至Set wsPerformanceLeague = Worksheets("PerformanceLeague")
您必须使用单词Set
关于vba - 将工作表传递给子例程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38697715/