+ Reply to Thread
Results 1 to 8 of 8

Help Optimizing Code

  1. #1
    Registered User
    Join Date
    05-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    4

    Help Optimizing Code

    Hi, I'm new VBA macro and understand you should optimize code where possible. Any thoughts on optimizing this:

    Please Login or Register  to view this content.
    All I'm doing is copying data from a column and pasting it a few columns over, moving a couple columns over and repeating this for 12 periods.
    There are 3 different period lengths.
    The first I'm pasting 6 columns over, then 4 columns over 8 times and finally 2 columns over 3 times.

    Any help would be great!

  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,258

    Re: Help Optimizing Code

    Hello tasugie,

    Welcome to the Forum!

    Recorded macros are difficult to optimize without the workbook. Please post your workbook and include any comments needed to explain what your desired outcome is.

    To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

    File Manger Picture
    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
    Registered User
    Join Date
    05-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Help Optimizing Code

    Ok Leith,
    I attached a workbook which has a macro button doing what I want it to do. It runs perfect.
    I just want to know if anyone out there can help optimize my code.
    Thanks!
    Attached Files Attached Files
    Last edited by tasugie; 05-06-2013 at 04:25 PM.

  4. #4
    Registered User
    Join Date
    05-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Help Optimizing Code

    Anybody, anybody, Bueller.....

  5. #5
    Registered User
    Join Date
    02-23-2012
    Location
    Almaty, Kazakhstan
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Help Optimizing Code

    May be you have to switch off ScreenUpdating
    Application.ScreenUpdating = False
    ' your code
    Application.ScreenUpdating = True

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help Optimizing Code

    See if this is what you wanted.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-04-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Help Optimizing Code

    jindon this is brilliant!
    One question though. Isn't this part repetitive b/c it gets handled in the first step of the loop?
    Please Login or Register  to view this content.

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: Help Optimizing Code

    OOPs, you are right.

    That line can be deleted.

+ 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