+ Reply to Thread
Results 1 to 6 of 6

running a piece of code in 4 separate sheets

  1. #1
    Forum Contributor
    Join Date
    11-22-2006
    MS-Off Ver
    2010
    Posts
    201

    running a piece of code in 4 separate sheets

    HI all, i have been using the following code in a sub Worksheet_Activate. However it means that whenever the sheet is activated the code runs each time.

    What i really want is for the code to run just once, say perhaps when the code is activated using a command button (i know how to do that).
    the problem is that there are 4 sheets i need the code to run on: page1, page2, page3 and page4.


    Is there a way to get the code to spool to each sheet and run this piece of code?

    Hope ive myself clear, thanks again. here is my code as it stands:

    Please Login or Register  to view this content.
    Luce

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: running a piece of code in 4 separate sheets

    Try this:

    Please Login or Register  to view this content.

    I'm a little confused as to why you are hiding Rows 150-454 after you seem to have looped through them.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Contributor
    Join Date
    11-22-2006
    MS-Off Ver
    2010
    Posts
    201

    Re: running a piece of code in 4 separate sheets

    Thanks Dom, that is excellent.
    I only hide the rows where the value in column A is not the same as the value in D1.
    Your help really is gratefully receved.
    Luce

  4. #4
    Forum Contributor
    Join Date
    11-22-2006
    MS-Off Ver
    2010
    Posts
    201

    Re: running a piece of code in 4 separate sheets

    Hi Dom, unfortunately the code doesnt work as expected. When I run the code it loops thru each sheet but hides every row. When I select one of the sheets (eg: page1) and run the code from that sheet it runs and hides the correct rows on that sheet only, on all the other sheets each row is hidden.

    Sorry, but cant figure out why it isnt working.
    thanks for your help.
    Luce

  5. #5
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: running a piece of code in 4 separate sheets

    Ooops, this might fix it...

    Please Login or Register  to view this content.

    Dom

  6. #6
    Forum Contributor
    Join Date
    11-22-2006
    MS-Off Ver
    2010
    Posts
    201

    Re: running a piece of code in 4 separate sheets

    That fixed it, THANKS !

+ 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