PDA

View Full Version : Cannot pass object to sub-procedure located in worksheet?



Hicmade
02-19-2019, 03:08 AM
Hi,
I spent a lot of time looking for a solution but with no luck.

I have created class CWpis in my 'Class Modules'. In 'Forms' i created sub procedure that collects data
from textboxes and put it to my CWpis new object. Then, I want to pass this object to sub-procedure
located in another worksheet:


Sub CommandButton1_Click()

Dim aaa As New CWpis
aaa.NumberUD = TextBox1.Value

Worksheets("Main").NewUD aaa

End Sub


This is sub-procedure in worksheet "main":


Public Sub NewUD(ByRef nUD As CWpis)

Debug.Print (nUD.NumberUD)

End Sub


What do I get is:
"Run-time error '40036':
Application-defined or object-defined error"

I can pass the same object to sub-procedure located in modules but cannot to worksheets? What is the
reason?:banghead:

Aflatoon
02-19-2019, 03:37 AM
Which version of Excel?

Hicmade
02-19-2019, 04:15 AM
Which version of Excel?

It's Excel 2013 - VBA 7.1