我试图通过传递某个sheetname作为参数来调用子例程,但是我收到以下错误:
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)
答案 0 :(得分:3)
将wsPerformanceLeague
声明为工作表。 Dim wsPerformanceLeague as Worksheet
将wsPerformanceLeague = Worksheets("PerformanceLeague")
更改为Set wsPerformanceLeague = Worksheets("PerformanceLeague")
您必须使用Set