+ Reply to Thread
Results 1 to 4 of 4

Cleaning all objects before macro exit

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Cleaning all objects before macro exit

    Hi Guys,

    it is a good practice to clean all VBA objects (like ranges, dictionaries) before macro exit?
    What do you think ?

    When should i do this?

    Jacek

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Cleaning all objects before macro exit

    Unless their scope means that they would remain in memory and you specifically don't want them to, it's generally a waste of time setting them to nothing in my opinion. (there are a few exceptions, such as when you have created cross-dependencies)
    Rory

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Cleaning all objects before macro exit

    Thanks Rory!

    Can you explain more about cross-dependecies what you mean?

    Jacek

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Cleaning all objects before macro exit

    It only really applies if you have created your own classes and one stores a reference to another, which in turn stores a reference back to the first one. In such case, simply setting the objects to nothing will have no effect anyway unless you have implemented code to release the other object. It's a very niche case, which is why I put it as an afterthought!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cleaning up macro code
    By rawku123 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2020, 05:02 AM
  2. [SOLVED] Text cleaning Macro
    By makinmomb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2015, 01:17 AM
  3. Cleaning up macro
    By jjcarter1988 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2013, 01:26 AM
  4. [SOLVED] Cleaning up a Recorded Macro
    By 6423joel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2013, 09:58 AM
  5. Cleaning the files using macro
    By swathidas in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-05-2011, 01:56 PM
  6. Help cleaning up a macro
    By gugg7378 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-23-2011, 01:23 PM
  7. all objects and userforms opened in a subroutine closed upon exit by default?
    By stanigator in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-11-2007, 09:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1