I am trying to learn how to get classes and collections to work together with userforms. How can I call a class module's stuff from a userform module? The userform calls a macro from a different regular module successfully.
The class module is public not private. The userform runs successfully except when the button is clicked that should call the class module. Then I get an error 424 object required msg. Or if I change the problem line I get a sub or function not defined error msg. for the same line. The line that says "Class1.whatever" below is the line that is highlighted to be debugged. Also I have gotten error messages for the line below it.
I put this in the userform module:
I put this in the "Class1" class module:
The class module is public not private. The userform runs successfully except when the button is clicked that should call the class module. Then I get an error 424 object required msg. Or if I change the problem line I get a sub or function not defined error msg. for the same line. The line that says "Class1.whatever" below is the line that is highlighted to be debugged. Also I have gotten error messages for the line below it.
I put this in the userform module:
Code:
Private Sub blah_Click()
Class1.whatever
Range("A1").Value = Class1.stuff.Item(1)
End Sub
I put this in the "Class1" class module:
Code:
Sub whatever()
Dim stuff As Collection
Set stuff = New Collection
stuff.Add "First thing in collection"
End Sub
Last edited: