Results 1 to 3 of 3

Thread: VBA - What variable types should be manually unloaded at the end of a macro
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Dec 2010
    Posts
    15
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question VBA - What variable types should be manually unloaded at the end of a macro

    Hi,

    I'm trying to make myself a cleaner coder, and hopefully write code that does not slow down every time I run it.

    Can anyone help me with a list of variable types that need to be set to nothing or unloaded from memory manually at the end of a macro?

    Thank you,
    Daniel

  2. #2
    Board Regular
    Join Date
    Dec 2008
    Posts
    6,645
    Post Thanks / Like
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA - What variable types should be manually unloaded at the end of a macro

    Anything that is declared as Static or Public, which is no longer needed. Everything else should automatically unload when the procedure ends.

  3. #3
    MrExcel MVP
    Moderator
    RoryA's Avatar
    Join Date
    May 2008
    Location
    UK
    Posts
    33,815
    Post Thanks / Like
    Mentioned
    48 Post(s)
    Tagged
    6 Thread(s)

    Default Re: VBA - What variable types should be manually unloaded at the end of a macro

    It depends on their scope. If they are local to the procedure they are used in, they will be cleared at the end anyway, so you don't need to do anything. If they are module level or public, and you don't need them stored, then clearing them is advisable.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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