Is there a generic way to clone objects in VBA? So that i could copy x to y instead of copying just the pointer?
Dim x As New Class1
Dim y As Class1
x.Color = 1
x.Height = 1
Set y = x
y.Color = 2
Debug.Print "x.Color=" & x.Color & ", x.Height=" & x.Height
By generic i mean something like Set y = CloneObject(x)
rather than having to create my own method for the class copying its properties one by one.
Scott Whitlock has posted a fantastic answer to this problem on another question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With