Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2016, 05:53 AM
m85miller m85miller is offline Writing a VBA code for printing multiple sheets in a workbook Windows 10 Writing a VBA code for printing multiple sheets in a workbook Office 2013
Novice
Writing a VBA code for printing multiple sheets in a workbook
 
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
  #2  
Old 02-02-2016, 01:41 AM
Debaser's Avatar
Debaser Debaser is offline Writing a VBA code for printing multiple sheets in a workbook Windows 7 64bit Writing a VBA code for printing multiple sheets in a workbook Office 2010 32bit
Competent Performer
 
Join Date: Oct 2015
Location: UK
Posts: 221
Debaser will become famous soon enough
Default

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
Reply With Quote
Reply



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
Writing a VBA code for printing multiple sheets in a workbook Reference another workbook and return values from the same cell across multiple sheets/tabs lwls Excel Programming 5 11-08-2014 02:11 PM
Writing a VBA code for printing multiple sheets in a workbook How add 3 footer items to all sheets in workbook? Mendopaul Excel 3 12-05-2013 02:32 PM
Writing a VBA code for printing multiple sheets in a workbook Combining 2 workbooks into 1 workbook with TWO sheets dguenther Excel 1 10-06-2011 03:25 AM
Writing a VBA code for printing multiple sheets in a workbook How do I merge data from one sheet in a workbook out into multiple sheets nolesca Excel 4 06-07-2010 08:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:16 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft