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
Bookmarks