View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default Remove object from memory

Lex

All you've done is created a reference. Then you've put some data there.
You've used it and then you've set it to nothing ... cleared it out.

Try:

Sub test()
Dim MyObject As Worksheet
Set MyObject = Worksheets(1)
MsgBox MyObject.Name
Set MyObject = Nothing
MsgBox MyObject.Name
End Sub

and see what happens.

Regards

Trevor


"lexcel" wrote in message
ups.com...

Thanks for the reply, but does this really remove the object from
memory as well?
What if I did the following:

Dim Fred as MyObject, George as New MyObject

Set Fred = George
Set George = Nothing

I could still access the same object through Fred, it is not erased
from memory.
For many built-in functions there is a Delete method, that is more like
what I am looking for.
Maybe may question should be:
How do I create a Delete method which frees the memory occupied by my
object?

With regards,

Lex