I have managed to wangle together this VBA code to select & print preview certain worksheets from the workbook. It works great, but I want to exclude certain sheets from the list.
I am hoping some VBA guru here can help me out please?
I want to exclude the following list of worksheets and make sure there are no blank items in the ActiveX combo box print list which is located on the Project Details worksheet:
Any help will be much appreciated.
Thanks
I am hoping some VBA guru here can help me out please?
VBA Code:
Sub Print_Sheets()
Dim i As Long, c As Long
Dim SheetArray() As String
'ERROR HANDLING
Dim errMsg As String
On Error GoTo errHandler
errMsg = "You Need To Select RAMS & COSHH To Print"
errHandler:
MsgBox errMsg
Exit Sub
'
With ActiveSheet.ListBoxSh
For i = 0 To .ListCount - 1
If .Selected(i) Then
ReDim Preserve SheetArray(c)
SheetArray(c) = .List(i)
c = c + 1
End If
Next i
Sheets(SheetArray()).PrintPreview
End With
End Sub
I want to exclude the following list of worksheets and make sure there are no blank items in the ActiveX combo box print list which is located on the Project Details worksheet:
- Project Details
- RA
- Lists
- COSHH Assessments
Any help will be much appreciated.
Thanks