+ Reply to Thread
Results 1 to 9 of 9

cleaning up recorded VBA

  1. #1
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    cleaning up recorded VBA

    can anyone help me clean this up... it is very slow, takes up to a minute or longer.

    Please Login or Register  to view this content.
    i actually have about 10 more pieces of code similiar to this, so im hoping i can fix the others from this one.
    Im horrible at VBA so any help is greatly appeciated

  2. #2
    Forum Contributor
    Join Date
    06-28-2016
    Location
    Pennsylvania, USA
    MS-Off Ver
    2013
    Posts
    308

    Re: cleaning up recorded VBA

    The problem is all of the selections.

    Select slows code down a lot.

    Without knowing how you are determining what to select, nobody can really help you, sorry.



    However, on a helpful note, instead of doing things like

    Range("A1").Select
    Selection.ClearContents

    Simply use:
    Range("A1").ClearContents

    Basically, name the range you are applying whatever function you desire, and do that function directly, instead of first selecting then applying that function to the selection.

    Apply the same logic when cleaning your code up, it will speed it up exponentially. If you require help further than that, try explaining how you are determining the selections.

    Something else that helps with larger pieces of code, is to turn screen updating, automatic calculations, etc. off prior to executing the code, then turning those things back on after.

  3. #3
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: cleaning up recorded VBA

    ty for the help Then... these are all pastes, so i would
    Please Login or Register  to view this content.
    like this?

  4. #4
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: cleaning up recorded VBA

    AF3:AN1012... that is the original area that is copied and special pasted to sheet titled "Wave"... the problem is, it overwrites a a SUM formula that is at every 10 to 12 rows on sheet "Wave"... so i have the simple Sum formula @ AQ11:AY11... i copy this and paste at the many "Selects"

    im sure their is an easier way, but this works, would just like to speed it up a bit, as i have a total of 10 buttons with a version of this code on each... so total of all buttons is 10+ minutes
    Last edited by keith740; 01-06-2017 at 02:17 PM.

  5. #5
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: cleaning up recorded VBA

    Range("A1").Paste

    i tried this with no success

  6. #6
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: cleaning up recorded VBA

    try this for the first copy/paste, see if it works
    Please Login or Register  to view this content.
    just test it...
    Please Login or Register  to view this content.
    Last edited by john55; 01-06-2017 at 05:27 PM.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  7. #7
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: cleaning up recorded VBA

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor keith740's Avatar
    Join Date
    04-24-2015
    Location
    Racine, Ohio
    MS-Off Ver
    MS365
    Posts
    241

    Re: cleaning up recorded VBA

    this took it down to a bit under 4 minutes... still slow but better

  9. #9
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: cleaning up recorded VBA

    did you try the 2nd one?
    instead of
    Please Login or Register  to view this content.
    with this one
    as far as I see you have step 11 rows, then 10 rows, then... pls adapt the below code and see if it works for you! much faster I think!
    Please Login or Register  to view this content.
    Last edited by john55; 01-07-2017 at 12:38 PM.

+ 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. [SOLVED] Recorded macro doing more than recorded?
    By Trending in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-26-2014, 11:42 AM
  2. [SOLVED] Cleaning up a Recorded Macro
    By 6423joel in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2013, 09:58 AM
  3. [SOLVED] Recorded Pivot Table Macro Doesn't Do What I Recorded!
    By diakonos1984 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-26-2013, 11:01 AM
  4. cleaning up a table
    By johndough185 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-18-2007, 06:16 PM
  5. #NA, cleaning data!
    By thardy in forum Excel General
    Replies: 7
    Last Post: 02-26-2007, 06:39 PM
  6. Data cleaning, HELP!
    By a303 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2007, 01:43 AM
  7. Spreadsheet cleaning
    By Richard in forum Excel General
    Replies: 3
    Last Post: 12-13-2005, 11:10 AM

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