Results 1 to 3 of 3

Macro to loop through sheets and print them out using an array

Threaded View

Masact Macro to loop through sheets... 08-04-2009, 03:23 PM
Leith Ross Re: Macro to loop through... 08-04-2009, 03:54 PM
Masact Re: Macro to loop through... 08-04-2009, 04:00 PM
  1. #1
    Registered User
    Join Date
    11-18-2008
    Location
    Richmond, VA
    Posts
    18

    Macro to loop through sheets and print them out using an array

    Hello,

    I have created a macro that loops through and creates an array of the visible sheets. Now I would like for it to print each of those sheets out. I think my main mistake is in my declaration of the array type, since I have not worked with arrays much before.

    Please help me figure out how to make the following code operable. Currently when I run it I'm getting a "Run-time error (9): Subscript out of range" error.

    Dim reference As Worksheet
    Dim outputsheets() As String
    Dim i As Integer
    
    Sub printing()
    '
    
        
        Sheets("Review").Select
        
        i = 0
        
        For Each reference In Sheets
            
            If reference.Visible = True Then
            
                outputsheets(i) = reference.Name
                i = i + 1
            
            End If
            
        Next
        
        ReDim Preserve outputsheets(i)
        
        Sheets(outputsheets()).Select
        ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    
    
    End Sub
    Thanks!
    Last edited by Masact; 08-04-2009 at 04:01 PM.

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