Question:
Print 1 or 2 Pages in Excel?
2012-12-05 12:07:30 UTC
I created a sales estimate program that searches a product description and price based on a product number, i created two sheets based on the length of the estimates we are asked to compile. I want to print only one page and if our sales reps put product on the second page to go ahead and print the second page.
Three answers:
garbo7441
2012-12-05 22:27:10 UTC
You can use a Workbook_BeforePrint event handler to set your print area, based on whether there is a value in the first row of the second sheet or not.



For example, the following event handler will evaluate cell A47 (the first cell in Page 2 based on my default settings). If A47 is blank, the print area will be set as A1:G46. If A47 is not blank, the print area will be set as A1:G92.



Copy the following code to the clipboard (highlight the entire code, right click inside the highlighted area, and Copy):



Private Sub Workbook_BeforePrint(Cancel As Boolean)

If ActiveSheet.Range("A47").Value = "" Then

ActiveSheet.PageSetup.PrintArea = "$A$1:$G$46"

Else

ActiveSheet.PageSetup.PrintArea = "$A$1:$G$92"

End If

End Sub



Press ALT + F11 (Function Key F11)



Double click 'This Workbook' in the Microsoft Excel VBA Project objects in the upper left quadrant.



Paste the event handler into the white editing area to the right (right click inside the area and 'Paste').



Close the VBE (red button w/white 'x' - upper right).



Call the Print function in the usual manner; File > Print, Ctrl + P, or create a command button with this macro attached:



Sub PrintPage ()

ActiveSheet.Printout

End Sub
2012-12-05 12:20:50 UTC
when u on a page & just want to that 1 only u hit Ctrl key+P the printer box will open select this page only, that also work when u want to print a part of a web page:)
cruickshank
2016-12-08 12:46:55 UTC
cut back the cells as much as achievable and than elect the section which you rather desire to print by using highlighting them and circulate as much as record and then print section, then set print section. circulate to print preview and if it nonetheless would not extra wholesome attempt changing the format o panorama somewhat of portrait- sturdy success


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...