Vba 将工作表传递给子程序

Vba 将工作表传递给子程序,vba,excel,Vba,Excel,我试图通过传递某个sheetname作为参数来调用子程序,但收到以下错误: Object doesn't support this property or method 这是我的密码: Public Sub PerformanceLeague() Dim wsPerformanceLeague As Worksheet Set wsPerformanceLeague = Worksheets("PerformanceLeague") SetHeadings wsPerformanceLea

我试图通过传递某个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)
  • wsPerformanceLeague
    声明为工作表<代码>将wsPerformanceLeague设置为工作表


  • wsPerformanceLeague=工作表(“PerformanceLeague”)
    更改为
    Set wsPerformanceLeague=工作表(“PerformanceLeague”)


  • 您必须使用单词
    Set

    wsPerformanceLeague=工作表(“PerformanceLeague”)
    将其更改为
    Set wsPerformanceLeague=工作表(“PerformanceLeague”)
    也在
    Dim wsPerformanceLeague as WORKEM中声明它
    您能告诉我们您在哪一行收到该错误消息吗?我已更新代码以匹配此错误,但我收到一个新错误,将更新主Post希望您删除行
    全局wsPerformanceLeague as WORKEM
    ?是的,全局行也已删除