ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Block Printing of sheet (https://www.excelbanter.com/excel-discussion-misc-queries/194162-block-printing-sheet.html)

Shu of AZ

Block Printing of sheet
 
I have two worksheets, sheet1 and sheet2. Is there code to block sheet1 from
printing without having to place the print area in some distant cell and
protect the sheet.

Mike H

Block Printing of sheet
 
Hi,

Alt + F11 to open VB editor. Double Click 'This Workbook' and paste this in
on the right

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = ("Sheet1") Then
MsgBox "You cannot print this sheet"
Cancel = True
End If
End Sub

Mike

"Shu of AZ" wrote:

I have two worksheets, sheet1 and sheet2. Is there code to block sheet1 from
printing without having to place the print area in some distant cell and
protect the sheet.



All times are GMT +1. The time now is 07:08 AM.

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