+ Reply to Thread
Results 1 to 3 of 3

Suggestions or Advice applying a macro to multiple worksheets

  1. #1
    Registered User
    Join Date
    08-28-2012
    Location
    New York
    MS-Off Ver
    Excel 2011
    Posts
    7

    Suggestions or Advice applying a macro to multiple worksheets

    Hello again. I have a macro for copying a formula to X number of rows. I am going to need to apply this macro to 21 worksheets. I have found 2 ways of doing this that "work". The first one uses this macro:


    Please Login or Register  to view this content.
    While this runs smoothly, it is limiting because ideally I will only want to apply this to 21 of 63 worksheets in my workbook.

    The second version uses an array and I know I can specify which sheets to apply it to, but Excel freezes when I run it:


    Please Login or Register  to view this content.
    I don't know if this is a limitation of my computer, the macro, both, or something else. If anybody has a simpler way to get this formula to only apply to specific worksheets, I would greatly appreciate it!

    Thanks
    Last edited by dshanman; 08-28-2012 at 09:40 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-07-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    354

    Re: Suggestions or Advice applying a macro to multiple worksheets

    I think the problem with your second macro is the "for each c" part. That part makes you go through each cell of A1:A1000 and repeat the copy paste operation 1000 times!

    I cana thin kof two easy solutions
    1, replace your for each c ... next c part with (UNTESTED)
    Please Login or Register  to view this content.
    or

    2. Use flag on the sheet to decide
    Please Login or Register  to view this content.
    Hopefully one of these works for you
    Regards,
    Vandan

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Suggestions or Advice applying a macro to multiple worksheets

    Since you're using sequentially named sheets as your desired targets, you can use this syntax, too:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ 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