+ Reply to Thread
Results 1 to 6 of 6

VBA Good Practice

  1. #1
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    VBA Good Practice

    I am using the code below at the start and of macros. If I have a macro within a macro should I have this code with just the parent macro or with both parent and child?
    If I have a command Button on a form that runs a macro should I use the code below?
    Thanks Sandy

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: VBA Good Practice

    I generally use those in my code if I want it to run faster and NOT deal with any events (in case you have any event triggers).
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: VBA Good Practice

    So if I use my code and there is an event trigger the event may not show?

    If I have a spreadsheet with a lot of vba coding, and the code only takes a millisecond to run without CodeStart & CodeEnd, and with it half a millisecond (I wont notice the difference) then why have it?

  4. #4
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: VBA Good Practice

    So if I use my code and there is an event trigger the event may not show?

    If I have a spreadsheet with a lot of vba coding, and the code only takes a millisecond to run without CodeStart & CodeEnd, and with it half a millisecond (I wont notice the difference) then why have it?

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: VBA Good Practice

    With events, you need to include them with the event themselves .EnableEvents = False, to avoid the events auto triggering.
    I think it is a good coding practice to have separate codes for screening updating and others. Imagine you are writing many small subs and all these subs require these savers. So, instead of repeating these lines in all subs, you put them in a separate codes,so when you need them just call them. This might not save you lots of time but "Do not repeat yourself". is a code modular practice.
    Try to insert and copy cells with and with screen updating, you will see the difference.
    Last edited by AB33; 12-06-2016 at 06:47 PM.

  6. #6
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: VBA Good Practice

    Thanks for all the help, Ive got a better idea now. Cheers Sandy.

+ 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. Good practice for working with variables?
    By OldManExcellor in forum Excel General
    Replies: 1
    Last Post: 01-12-2016, 11:16 AM
  2. How to practice VBA?
    By Kayote in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-11-2009, 06:55 AM
  3. [SOLVED] Best Practice
    By CWillis in forum Excel General
    Replies: 2
    Last Post: 06-27-2006, 11:45 AM
  4. [SOLVED] Best Practice
    By Nellie in forum Excel General
    Replies: 2
    Last Post: 03-30-2006, 07:10 AM
  5. [SOLVED] Good Practice
    By Ardus Petus in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-22-2006, 04:10 PM
  6. Best Practice
    By Ardus Petus in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-19-2006, 11:14 PM
  7. Which folder - good practice?
    By Sunbank in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-13-2006, 09:35 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