+ Reply to Thread
Results 1 to 5 of 5

Multiple sheets PageSetup

  1. #1
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Multiple sheets PageSetup

    Trying to use this to pagesetup only certain sheets in a workbook, but get Runtime error 9, Subscript out of range using this code. It faults out on the Sheets(Array... line. Can someone help? Thanks.
    Please Login or Register  to view this content.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Multiple sheets PageSetup

    Put Option Explicit at the top of the module and debug. Do you get a "variable not defined error" highlighting one of the sheets?
    Ben Van Johnson

  3. #3
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Multiple sheets PageSetup

    Hi Ben, I have Option Explicit already. Now I get "Run time error 1004" and "Select method of sheets class failed".

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Multiple sheets PageSetup

    In this case, "Subscript out of range" may mean that either Sheet1, Sheet2 or Sheet3 has been deleted (and a new sheet added with the old tab nae). Do You see those exact sheets in project view? Does the code run if you replace Sheet.name with the tab name?

  5. #5
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Multiple sheets PageSetup

    Quote Originally Posted by protonLeah View Post
    In this case, "Subscript out of range" may mean that either Sheet1, Sheet2 or Sheet3 has been deleted (and a new sheet added with the old tab nae). Do You see those exact sheets in project view? Does the code run if you replace Sheet.name with the tab name?
    Yes, those sheets are there, if I hover over sheet#.name it shows the sheet name. No, it does not run if I replace sheet.name with worksheet name. Puzzling, cause it works in another workbook.

+ 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. Replies: 1
    Last Post: 06-28-2019, 02:32 AM
  2. Merge multiple excels with multiple sheets in a master excel with multiple sheets
    By marchi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-15-2012, 10:37 AM
  3. Edit PageSetup for All Sheets
    By driffert in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2008, 10:29 AM
  4. Activesheet.pagesetup
    By Spenceley in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-04-2006, 12:55 PM
  5. Setting PageSetup Properties in Multiple Worksheets
    By Josh Sale in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-28-2006, 02:25 PM
  6. [SOLVED] PageSetup
    By Stanley in forum Excel General
    Replies: 1
    Last Post: 12-14-2005, 03:25 PM
  7. PageSetup
    By Simon Shaw in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-28-2005, 09:05 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