View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Execute class method on all worksheets?

In principle you can call a method within a class passing an object to it,
so yes. But the class method would have to accept a worksheet as an
argument. The syntax would be

In the class

Function myMethod (sh As Worksheet)
Msgbox sh.Name
End Function

and in the general module

Set myObject = New class_name

For Each ws In Activeworkbook.Worksheets
MyObject.MyMethod ws
Next ws


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Nik" wrote in message
oups.com...
Hi,

I have an class instance on all my worksheets, is there some way I
can dynamically execute a method on these objects? Something like

for each worksheet in worksheets
worksheet.myObject.myMethod
next worksheet

?