+ Reply to Thread
Results 1 to 4 of 4

With statements with multiple sheets

  1. #1
    Registered User
    Join Date
    11-18-2008
    Location
    Richmond, VA
    Posts
    18

    With statements with multiple sheets

    Is it possible to have one with statement that affects more than one sheets at a time? For example (this is really simple):

    Please Login or Register  to view this content.
    I am getting an error when trying this and can't seem to find a way around it.

    Reason I ask is because I have a good deal of code that is setting print ranges on one tab, and now I have two of these same tabs, and would like to try to avoid having the same with statement twice, once for each sheet. Any ideas??

    Thanks in advance.

  2. #2
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: With statements with multiple sheets

    Based on your script example this is what I came up with?

    Please Login or Register  to view this content.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: With statements with multiple sheets

    Hello Masact,

    The With statement can be applied only to a single object. You could use realniceguy5000's solution or use a loop.

    Loop through Sheets
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845

    Re: With statements with multiple sheets

    Hi,

    Also try

    Please Login or Register  to view this content.
    Charles

    There are other ways to do this, this is but 1 !
    Be Sure you thank those who helped.
    IF YOU'RE SATISFIED BY ANY MEMBERS RESPONSE TO YOUR ISSUE PLEASE USE THE STAR ICON AT THE BOTTOM LEFT OF THE POST UNDER THEIR NAME.

+ 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