With the code example below I'm trying to loop through the collection and call a few custom class functions. What I'd like to do is loop through an array of the class functions and call them using application.run().
In the example below the "IsWidthOK" function would run, then I would loop to the "IsDepthOK" function, etc. Is that possible when it is a custom class function, and not macro? I've tried a few different variations like the function in quotes, then not, then fully qualified, etc. Usually get a cannot run macro.." error, or sometimes a 2015 error. Is there a way to do this? Or an alternative that is similar? Otherwise I'll need to right several functions within that loop, which I'm trying to avoid. Thanks.
In the example below the "IsWidthOK" function would run, then I would loop to the "IsDepthOK" function, etc. Is that possible when it is a custom class function, and not macro? I've tried a few different variations like the function in quotes, then not, then fully qualified, etc. Usually get a cannot run macro.." error, or sometimes a 2015 error. Is there a way to do this? Or an alternative that is similar? Otherwise I'll need to right several functions within that loop, which I'm trying to avoid. Thanks.
Code:
ArrayOfFunctions = Array("IsWidthOK", "IsDepthOK", etc.)
For Each clsPOG In colPOGs
For Each clsShelf In clsPOG.Shelves
If clsShelf.ShelfType = MyType Then
With clsShelf
for i = lbound(ArrayOfFunction) to ubound(ArrayOfFunctions)
myvar = Application.Run(ArrayOfFunctions(i))
'do something with myvar...
next i
End With
End If
Next clsShelf
Next clsPOG