Results 1 to 5 of 5

print sheets BY array values

Threaded View

petix print sheets BY array values 10-23-2013, 11:45 PM
jolivanes Re: print sheets BY array... 10-24-2013, 01:06 AM
petix Re: print sheets BY array... 10-24-2013, 02:15 AM
jolivanes Re: print sheets BY array... 10-25-2013, 04:46 PM
petix Re: print sheets BY array... 10-29-2013, 06:51 AM
  1. #1
    Registered User
    Join Date
    10-23-2013
    Location
    Prague
    MS-Off Ver
    Excel 2010
    Posts
    3

    Question print sheets BY array values

    Hi experts, I'm new to VBA as well as to this forum.

    I have a code which, based on the checkboxes checked, fills the array SNarray with names of worksheets.
    Then I need to use this list of worksheets for printing them out - I need to do it at one printing job....not sheet by sheet. And excel is giving me back the famous "error no. 9 - Subscript out of range"
    Sub Multi_printing()
        Application.ScreenUpdating = False
        
    Dim a As Integer
    Dim SNarray(1 To 6) As String
    Dim i
    
    Sheets("Setup").Select
    
    'ReDim SNarray(1 To Sheets.Count)
    a = 1
    For i = 1 To (Sheets.Count - 2)
        If ActiveSheet.OLEObjects("CheckBox" & i).Object.Value = True Then
             SNarray(a) = ThisWorkbook.Sheets(i).Name '& ", "
            'Debug.Print SNarray(a)
            a = a + 1
        End If
    Next
    
    'This works fine and prints out the certain worksheet as the possition in the array is given
    Sheets(SNarray(2)).PrintOut , , 1
    
    'This works NOT and produces the error
    Sheets(SNarray).PrintOut , , 1
    
    Application.ScreenUpdating = True
         
    End Sub

    Any idea how to address all the array's values and pass them all together as an argumet?

    thanks a lot
    Last edited by Leith Ross; 10-24-2013 at 12:02 AM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to loop through sheets and print them out using an array
    By Masact in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2009, 04:00 PM
  2. [SOLVED] Print Array for hidden sheets using VBA
    By Ant in forum Excel General
    Replies: 1
    Last Post: 03-27-2006, 06:24 AM
  3. Print Array for hidden sheets using VBA
    By Ant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2006, 04:30 AM
  4. Print Array for hidden sheets using VBA
    By Ant in forum Excel General
    Replies: 0
    Last Post: 03-22-2006, 12:35 PM
  5. [SOLVED] Creating an array of sheets to print
    By Luc Dansereau in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2005, 01:05 PM

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