Please enlighten me as to why the for loop causes me to lose the array when it is placed in the UserForm Initialize sub. If I position Unload Me underneath PrintOut, Me will take its place. The array is successfully passed with hide enabled. Yet, even with Unload Me at the beginning, as demonstrated below, rpvSheet is passed appropriately.
''Declare variables
Dim recapArr() As Long, i As Long, j As Long, rpvSheet as Long
Private Sub CommandButton1_Click()
Unload Me
''Print preview
If CheckBox2 = True Then Worksheets(recapArr).PrintOut Copies:=TextBox1.Value, Preview:=True
If CheckBox3 = True Then Worksheets(rpvSheet).PrintOut Copies:=TextBox1.Value, Preview:=True
End Sub
Private Sub CommandButton2_Click()
Unload Me
''Direct print
If CheckBox2 = True Then Worksheets(recapArr).PrintOut Copies:=TextBox1.Value
If CheckBox3 = True Then Worksheets(rpvSheet).PrintOut Copies:=TextBox1.Value
End Sub
Private Sub UserForm_Initialize()
''Check for hidden sheets that will not print
j = 0
For i = 3 To 4
If Sheets(i).Visible = True Then
ReDim Preserve recapArr(j)
recapArr(j) = Sheets(i).Index
j = j + 1
End If
Next i
If Sheet5.Visible = True Then rpvSheet = 5
If Sheet6.Visible = True Then rpvSheet = 6
End Sub