humbleprogrammer
Programmer
Hello,
I have a form with a combo box that allows you to select the worksheet you want to print. When choosing "ALL", it works correctly but when choosing a specific worksheet, it give a subscript out of range error. Below is my code. Any help is appreciated.
I have a form with a combo box that allows you to select the worksheet you want to print. When choosing "ALL", it works correctly but when choosing a specific worksheet, it give a subscript out of range error. Below is my code. Any help is appreciated.
Code:
Private Sub btnPrint_Click()
Dim PrintSheet As String
PrintSheet = frmSelectSheet.cmbSelectSheet.Value
If PrintSheet <> "ALL" Then
Application.ScreenUpdating = False
frmSelectSheet.Hide
Sheets(" & PrintSheet & ").Activate
Sheets(" & PrintSheet & ").PrintOut
MsgBox PrintSheet & " was successfully printed.", vbInformation, "Successfully Printed"
frmSelectSheet.Show
Application.ScreenUpdating = True
Else
Application.ScreenUpdating = False
frmSelectSheet.Hide
Sheets("SURF WAX").Activate
Sheets("SURF WAX").PrintOut
Sheets("SURF ACCESS").Activate
Sheets("SURF ACCESS").PrintOut
Sheets("SNOW WAX").Activate
Sheets("SNOW WAX").PrintOut
Sheets("SNOW ACCESS").Activate
Sheets("SNOW ACCESS").PrintOut
Sheets("SOFTGOODS").Activate
Sheets("SOFTGOODS").PrintOut
Sheets("ALOE UP").Activate
Sheets("ALOE UP").PrintOut
Sheets("Solarez&ASSi").Activate
Sheets("Solarez&ASSi").PrintOut
MsgBox ("All worksheets were successfully printed."), vbInformation, "Successfully Printed"
frmSelectSheet.Show
Application.ScreenUpdating = True
End If
End Sub