ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   setting complex print area (https://www.excelbanter.com/excel-programming/274604-re-setting-complex-print-area.html)

William[_2_]

setting complex print area
 
Hi

Can you not format the area you do not want printed to ....
Range("D5:D10").NumberFormat = ";;;"
and reinstate the correct format after printing.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
'Remove the following line below when you do the range printed
Range("D5:D10").NumberFormat = ";;;"
ActiveSheet.PageSetup.PrintArea = _
"$C$3:$D$19,$F$12:$H$22,$J$20:$L$31,$F$32:$G$41,$B $35:$D$47"
ActiveSheet.PrintOut
Range("D5:D10").NumberFormat = "#,##0 ;[Red](#,##0)"
Application.EnableEvents = True
End Sub



--
XL2002
Regards

William


"Wild Bill" wrote in message
...
| I am trying to hide or "mask out" a section of a sheet from printing.
| E.g. I want to prevent B5 through D10 from printing. I do *not* want to
| do so permanently, so just building a print area with control-clicks is
| no good (if that even works).
|
| I'll use VBA to toggle it. The nuisance here is that the shape of the
| rest that I DO want to print is odd, making me need to specify the print
| area as something like
| "A:A;B1:D4;B11:D65535;E:IV"
| which, even if that works, is too hardcoded (e.g. what if I modify the
| range to be masked?).
|
| Well I did set up a range for the masked area but still don't know how
| to hide it from printing.
| Range properties considered:
| .hidden: only works for full rows or columns
| .visible: is not a property for ranges
| .characters: This has promise. Maybe I can switch the color to white
| during printing.
|
| Changing column widths: Nope, affects cells above and below my
| mask-range.
|
| Am I missing the obvious solution?




All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com