2016-08-01 63 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