Jan Karel Pieterse wrote:You could move the a-z module's code to a class module instead. Then you can have a single variable holding an instance of the class. If you set that instance variable to nothing the class (and its a-z properties) instance is zapped.
Thank you Jan Karel
In attempt to fully understand your advice I created a class module named TC. The complete code follows.
Code: Select all
Public A As Variant
Public B As Variant
Option Explicit
In a standard module I placed the following code
Code: Select all
Option Explicit
Public Sub Test()
Dim TMP As TC
Dim mva As Variant
Dim mvb As Variant
10 Set TMP = TC
20 TMP.A = "Variable A"
30 TMP.B = "Variable B"
40 mva = TMP.A
50 mvb = TMP.B
60 Set TMP = Nothing
End Sub
This code throws an error at line 10, yet without it I get the error "Object variable or With block variable not set"
Can you advise me on my error?