Reputation: 444
I am trying to call a sub routine by passing a certain sheetname as the parameter, but I receive the following error:
Object doesn't support this property or method
Here is my code:
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
I have tried calling the sub routine as below as well, but receive the same error:
Call SetHeadings(wsPerformanceLeague)
Upvotes: 2
Views: 595
Reputation: 149315
Declare wsPerformanceLeague
as worksheet. Dim wsPerformanceLeague as Worksheet
Change wsPerformanceLeague = Worksheets("PerformanceLeague")
to Set wsPerformanceLeague = Worksheets("PerformanceLeague")
You have to use the word Set
Upvotes: 3