View Single Post
 
Old 11-17-2013, 01:39 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Private Sub CommandButton1_Click()
Dim wkSht As Worksheet, Ctrl As Control, i As Long, ArrShts()
ReDim Preserve ArrShts(0)
For Each Ctrl In Me.Controls
  With Ctrl
    If .Name Like "CheckBox#*" Then
      If .Value = True Then
        ReDim Preserve ArrShts(i)
        ArrShts(i) = .Caption
        i = i + 1
      End If
    End If
  End With
Next
If ArrShts(0) = 0 Then GoTo NoPrint
With ActiveWorkbook
  Set wkSht = .ActiveSheet
  .Sheets(ArrShts).Select
  Application.Dialogs(xlDialogPrint).Show Arg1:=1, Arg4:=1, Arg5:=False, Arg6:=True, Arg7:=1
  wkSht.Activate
End With
NoPrint:
Unload UserForm1
End Sub
 
Private Sub UserForm_Initialize()
Dim Ctrl As Control, i As Long, ArrShts()
ArrShts() = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", _
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", _
  "Jan (2)", "Feb (2)", "Mar (2)", "Apr (2)", "May (2)", "Jun (2)", _
  "Jul (2)", "Aug (2)", "Sep (2)", "Oct (2)", "Nov (2)", "Dec (2)")
  For Each Ctrl In Me.Controls
    With Ctrl
      If .Name Like "CheckBox#*" Then
        .Caption = ArrShts(i)
        i = i + 1
      End If
    End With
  Next
End Sub
Note: I couldn't help fiddling with your UserForm_Initialize sub a bit more ... The only change of substance is:
If ArrShts(0) = 0 Then GoTo NoPrint
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote