Reputation: 125
If you check out my history you will see that I have been calling Worksheets references through method calls. A working example of one such method:
'In module GlobalRefs
Function W_ExampleWS() As Worksheet
Set W_ExampleWS = ActiveWorkbook.Worksheets("ExampleWS")
End Function
So when I do normal worksheet related calls, they work:
...
GlobalRefs.W_ExamplesWS.Range("A1").Value = 42 'works
...
However, the worksheet ExampleWS has a subroutine called "DesignGraph". I want to be able to call that subroutine through a method call like so.
'In module AnotherRandomModule
...
GlobalRefs.W_ExampleWS.DesignGraph arg1 arg2
...
I keep receiving errors like the method is undefined even though the VBA Editor's intellisense acknowledges the the existence of the subroutine as it corrects the capitalization of DesignGraph if spelt mis-cased. I am giving it the correct arguments.
Why is this happening?
Upvotes: 0
Views: 379
Reputation: 3410
the Worksheet class does not have a DesignGraph method - only your specific sheet does. Assuming DesignGraph is a public sub, if you change the function to return an Object instead you should not have an issue.
Upvotes: 1