+ Reply to Thread
Results 1 to 4 of 4

Run a Macro on Several other Worksheets without leaving the current one

  1. #1
    Registered User
    Join Date
    11-02-2010
    Location
    Cirencester, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Run a Macro on Several other Worksheets without leaving the current one

    Hi,

    I have the below code:

    Please Login or Register  to view this content.
    The idea is that it goes through each worksheet and runs a macro on that worksheet, however it does not run on every worksheet only on SHEET4. The only way I can get it to run on every worksheet is to use the following code:

    Please Login or Register  to view this content.
    With ws.Activate on line 7 being the key part. However this results in screen flickering as it goes through every worksheet and this isn't ideal! I have tried a variety of different methods including Application.ScreenUpdating etc however with no luck.

    Anybody got any ideas??

    Many thanks.

    Harry

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Run a Macro on Several other Worksheets without leaving the current one

    Harry, the key is the code you're invoking and how it's constructed.

    I suspect you should be passing a Sheet reference to that routine (ie via a variable), subsequently applying With Statements within that routine so as to ensure the code is applied to the appropriate object.

  3. #3
    Registered User
    Join Date
    11-02-2010
    Location
    Cirencester, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Run a Macro on Several other Worksheets without leaving the current one

    Here is a little snippet of the code for Module11.PricelistChange:

    Please Login or Register  to view this content.
    Based on the above can you see anything that would mean only the .Activate method would allow the update of each sheet?

    Cheers,
    Harry

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Run a Macro on Several other Worksheets without leaving the current one

    Without wanting to get too involved I will just elaborate on my earlier point by means of example...

    Please Login or Register  to view this content.
    and in Module11

    Please Login or Register  to view this content.

+ 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