+ Reply to Thread
Results 1 to 9 of 9

Speedup VBA and Apply to all visible sheets

  1. #1
    Registered User
    Join Date
    02-23-2014
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    73

    Speedup VBA and Apply to all visible sheets

    Dear Experts!

    I have recorded a macro for some cleaning/formatting purpose which will rearrange my excel sheet. I need to run this macro on every visible sheets and speedup the process.

    Can anyone help me in this regards.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Speedup VBA and Apply to all visible sheets

    You've got a lot of Select and Activate going on, especially at the beginning of your code....
    Please Login or Register  to view this content.
    You are selecting a "range" of columns, then activating a specific cell, then selecting another range of columns and activating another specific cell. Looks to me as if all that is unnecessary.
    To speed it up, try this...
    Please Login or Register  to view this content.
    Last edited by gmr4evr1; 08-07-2016 at 12:13 PM.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Speedup VBA and Apply to all visible sheets

    Totally untested (so test on a copy of your workbook)...

    Please Login or Register  to view this content.
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  4. #4
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Speedup VBA and Apply to all visible sheets

    Quote Originally Posted by gmr4evr1 View Post
    You are selecting a "range" of columns, then activating a specific cell, then selecting another range of columns and activating another specific cell. Looks to me as if all that is unnecessary.
    Please Login or Register  to view this content.
    @gmr4evr1, I think you are misunderstanding what the macro recorder produces.
    If you turn on the recorder then hold down Ctrl and select a few columns (say for instance A,D,F) then you will find that it produces an Activate line which is the first cell of the last column selected (in the case of A,D,F it would produce the below code).
    The Column is still selected.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Speedup VBA and Apply to all visible sheets

    Ok, now I understand that part of it, but, isn't the selecting/activating unnecessary?

  6. #6
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Speedup VBA and Apply to all visible sheets

    Still totally unnecessary (I didn't use it either and I ignored the C8 and scroll at the end because it just looks like the OP was scanning the sheet before they turned off the recorder but I might be wrong).
    The OP needed the entire columns deleted rather than a cell and I could see where you were getting it from so I thought it might be of some use to explain what I could see.

  7. #7
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Speedup VBA and Apply to all visible sheets

    Gotcha...thanks for the info.

  8. #8
    Registered User
    Join Date
    02-23-2014
    Location
    Qatar
    MS-Off Ver
    Excel 2010
    Posts
    73

    Re: Speedup VBA and Apply to all visible sheets

    Thanks Guys. Unfortunately i am getting an error. (Attached)
    Attached Images Attached Images

  9. #9
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    882

    Re: Speedup VBA and Apply to all visible sheets

    Not my code but unmerge your cells (and do a Google on Centre across selection).
    I also don't see how your original code worked if you have merged cells.
    Last edited by WasWodge; 08-08-2016 at 02:18 AM.

+ 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] apply formula to only those rows that are visible after sort
    By mlski4751 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-08-2016, 03:54 AM
  2. Only apply formula for visible cells isn't working
    By cyborg31 in forum Excel General
    Replies: 4
    Last Post: 02-17-2016, 03:57 PM
  3. [SOLVED] how do you apply formatting to just visible cells?
    By ammartino44 in forum Excel General
    Replies: 4
    Last Post: 05-06-2014, 08:01 PM
  4. Replies: 4
    Last Post: 01-06-2014, 02:14 AM
  5. Apply COUNTIF to visible cells in a range
    By Belthasar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-21-2013, 05:15 AM
  6. Apply formula only to visible cells after filtering
    By excelnd in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-28-2012, 06:47 AM
  7. Apply formula only to visible cells
    By Fatboy10 in forum Excel General
    Replies: 2
    Last Post: 06-17-2012, 07:34 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