2016-08-01 80 views
2

我试图通过传递一定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) 
+2

'wsPerformanceLeague =工作表( “PerformanceLeague”)'将其更改为'设置wsPerformanceLeague =工作表( “PerformanceLeague”) ' –

+2

同时在'Dim wsPerformanceLeague作为工作表'声明它' –

+0

您能告诉我们您收到哪条错误消息吗? –

回答

3
  1. 声明wsPerformanceLeague作为工作表。 Dim wsPerformanceLeague as Worksheet

  2. 变化wsPerformanceLeague = Worksheets("PerformanceLeague")Set wsPerformanceLeague = Worksheets("PerformanceLeague")

你必须使用这个词Set

+0

我已更新代码来匹配这个,但我得到一个新的错误,将更新主文章 – Stuart1044

+0

希望你删除行'全球wsPerformanceLeague作为工作表'? –

+0

是的,全球线也被删除 – Stuart1044