View Single Post
 
Old 01-26-2016, 05:53 AM
m85miller m85miller is offline Windows 10 Office 2013
Novice
 
Join Date: Jan 2016
Posts: 1
m85miller is on a distinguished road
Default Writing a VBA code for printing multiple sheets in a workbook

Good Morning-

I have a small workbook of 6 tabs. I want three of those tabs (Cover Page, Supporting Evidence, and Recommendations) to print every time you press a command button and the other three (Waiver, LSC, IPC) I want it to look at a specific cell and if that cell has a check mark to then print that page as well. I want them to stay in order and also give page numbers when printed.

Right now this code is printing all the pages.

Here is the code I am currently using:

Private Sub CommandButton1_Click()
For Each ws In Worksheets
Select Case ws.Name

Case "Cover Page"
ws.PrintPreview

Case "Supporting Evidence"
ws.PrintPreview

Case "Recommendations"
ws.PrintPreview

Case "Waiver"
ws.PrintPreview

Case "LSC"
ws.PrintPreview

Case "IPC"
ws.PrintPreview

End Select

Next

End Sub

I was given some help and have updated the code to:

Case "Waiver"
If WS.Range("A6", "F6") = ChrW(&H2713) Then 'or ChrW(&H2714) for heavy checkmark
WS.PrintPreview
End If
Case "Lump Sum Compromise"
If WS.Range("A6","F6") = ChrW(&H2713) Then
WS.PrintPreview
End If
Case "Installment Plan Compromise"
If WS.Range("A6","F6") = ChrW(&H2713) Then
WS.PrintPreview
End If

However I am still not getting the 3 option pages (Waiver, LSC and IPC) to print if I have a checked box in cell "A6" or "F6". Below I have tried to update the code to go to each sheet and look at 2 cells for a checked box (the checked box I am using is from the ActiveX Controls and I have named each check box, for example on the "waiver" sheet the names of the checked boxes are cbW1 and cbW2. Any further assistance would be greatly appreciated.

I am getting a Run-time error '13: Type mismatch

Thanks in advance for the help!
Reply With Quote