+ Reply to Thread
Results 1 to 5 of 5

Deleting parameters to save running time?

  1. #1
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Deleting parameters to save running time?

    I notice that some instructions in my macros can be shortened, thereby saving nanoseconds of running time (presumably !), and the end result of the operation is still the same.
    But is it so? Are there any drawbacks? is the time saved worth it, when I have to run many such instructions?
    Some instances:

    1)
    Please Login or Register  to view this content.
    shortened to
    Please Login or Register  to view this content.
    2)
    Please Login or Register  to view this content.
    shortened to
    Please Login or Register  to view this content.

    3)
    Please Login or Register  to view this content.
    shortened to
    Please Login or Register  to view this content.
    Thanks for any enlightened answer.
    ACA
    Last edited by aca; 03-06-2012 at 03:32 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Deleting parameters to save running time?

    Hello aca,

    (1) When programming in VBA, it seldom necessary to Activate an object before an operation can be performed. Activating an object wastes a lot time as this primarily done for visual presentation.

    (2 & 3) Objects generally assign default values to all the properties they contain. However, the help files do not always provide that information. Generally, you do not have to set all the properties of an object as these values remain in effect only for the lifetime of the object. Two notable exceptions are the Find and Replace methods for a Range object. Most all of the values are retained because VBA hooks into the Windows Find and Replace dialog.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Deleting parameters to save running time?

    Following up on what Leith said, if you do something simple like find/ replace or copy/ paste in a few cells, then you (as a human) will not feel any added advantage to learn efficient coding practices. Now on the other hand, if you are going through a million cells and doing the same task then efficiency can save you hours to days of headache. You can even time these processes (through vba) to see exactly how long two different processes really took. I have some codes that runs for days at a time and so every minor tweaks shaves off unneeded time to complete the task.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  4. #4
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Re: Deleting parameters to save running time?

    Thanks, Leith, and you abouceta, for your help. Very useful and, for me, insightful.
    ACA

  5. #5
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Deleting parameters to save running time?

    Hi,

    If you are satisfied with the responses, then please mark the thread as Solved (instructions in the Forum Rules and FAQs).

    Good luck.

    abousetta

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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