#1
|
|||
|
|||
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! |
#2
|
||||
|
||||
You can't check a range of cells like that (you're also actually testing range A6:F6, not just two cells).
You need separate checks: Code:
If WS.Range("A6").Value2 = ChrW(&H2713) Or WS.Range("F6").Value2 = ChrW(&H2713) Then |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vba code for integrating particular information from different workbook to one workbook | klpw | Excel Programming | 1 | 12-28-2015 09:48 AM |
Reference another workbook and return values from the same cell across multiple sheets/tabs | lwls | Excel Programming | 5 | 11-08-2014 02:11 PM |
How add 3 footer items to all sheets in workbook? | Mendopaul | Excel | 3 | 12-05-2013 02:32 PM |
Combining 2 workbooks into 1 workbook with TWO sheets | dguenther | Excel | 1 | 10-06-2011 03:25 AM |
How do I merge data from one sheet in a workbook out into multiple sheets | nolesca | Excel | 4 | 06-07-2010 08:13 AM |