aggiemarine07
New Member
- Joined
- Nov 5, 2013
- Messages
- 46
Howdy all! I have a question for the general audience about trying to print specific pages in my workbook. I've found a few places on the internet that pointed me in the right direction but I think my VBA code is a little in-efficient. It gets the job done but it does it in a slightly annoying way.
What I am trying to do is print out pages 162 to 169 of my workbook, these pages are used in a presentation to my boss once a quarter. Pages 162, 163, 167, 168, 169 are static one page documents. However pages 164, 165, and 166 are dynamic. On these pages it lists the number of drops we've had from our training program. These drops can be as short as half a page and sometimes the full three pages.
I put together some VBA that allows me to print the static pages and the dyanmic pages (based on a value in O2) easily but when I run my macro it prints it into three seperate PDF documents. I want it to print into one document but I cant seem to figure out how. Here is the code:
Sub Print_Specific_Pages()
ThisWorkbook.PrintOut From:=162, To:=163
ThisWorkbook.PrintOut From:=167, To:=169
If Worksheets("EOC p3 Line Drops").Range("O2").Value < 50 Then
ThisWorkbook.PrintOut From:=164, To:=164
ElseIf Worksheets("EOC p3 Line Drops").Range("O2").Value < 101 Then
ThisWorkbook.PrintOut From:=164, To:=165
ElseIf Worksheets("EOC p3 Line Drops").Range("O2").Value < 152 Then
ThisWorkbook.PrintOut From:=164, To:=166
End If
End Sub
How can I make it better? Thanks in advance!
What I am trying to do is print out pages 162 to 169 of my workbook, these pages are used in a presentation to my boss once a quarter. Pages 162, 163, 167, 168, 169 are static one page documents. However pages 164, 165, and 166 are dynamic. On these pages it lists the number of drops we've had from our training program. These drops can be as short as half a page and sometimes the full three pages.
I put together some VBA that allows me to print the static pages and the dyanmic pages (based on a value in O2) easily but when I run my macro it prints it into three seperate PDF documents. I want it to print into one document but I cant seem to figure out how. Here is the code:
Sub Print_Specific_Pages()
ThisWorkbook.PrintOut From:=162, To:=163
ThisWorkbook.PrintOut From:=167, To:=169
If Worksheets("EOC p3 Line Drops").Range("O2").Value < 50 Then
ThisWorkbook.PrintOut From:=164, To:=164
ElseIf Worksheets("EOC p3 Line Drops").Range("O2").Value < 101 Then
ThisWorkbook.PrintOut From:=164, To:=165
ElseIf Worksheets("EOC p3 Line Drops").Range("O2").Value < 152 Then
ThisWorkbook.PrintOut From:=164, To:=166
End If
End Sub
How can I make it better? Thanks in advance!