ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   deny printing for certain blank cells (https://www.excelbanter.com/excel-worksheet-functions/160690-deny-printing-certain-blank-cells.html)

huntnpeck2

deny printing for certain blank cells
 
How do I make a macro button that will return the user back to the
spreadsheet if certain cells are not filled in?

Thanks,
Tim

Roger Whitehead[_2_]

deny printing for certain blank cells
 
Use the BeforePrint event in the ThisWorkbook module. Are you familiar with
this?
Here is some sample code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
'BOTH cells must contain data before printing-
If Application.WorksheetFunction.CountA(Range("A1,C25 ")) < 2 Then
Cancel = True
MsgBox "A1 and C25 must have values"
End If
End Sub

--
---
HTH
Roger
Shaftesbury (UK)
(Excel 2003, Win XP/SP2)





"huntnpeck2" wrote in message
...
How do I make a macro button that will return the user back to the
spreadsheet if certain cells are not filled in?

Thanks,
Tim




Darren Bartrup[_2_]

deny printing for certain blank cells
 
Add this code to the ThisWorkbook code:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Sheet1").Cells(1, 1) = "" Then
MsgBox "Cancelled"
Cancel = True
End If
End Sub

If Cell A1 on Sheet1 is empty then the print job will be cancelled.

"huntnpeck2" wrote:

How do I make a macro button that will return the user back to the
spreadsheet if certain cells are not filled in?

Thanks,
Tim



All times are GMT +1. The time now is 04:32 PM.

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