ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Check for value before printing... (https://www.excelbanter.com/excel-programming/341593-check-value-before-printing.html)

shikamikamoomoo[_5_]

Check for value before printing...
 

I am looking for a code that will do the following:

Before printing look for...

If D17 0 then D28 must be 0 AND
If F17 0 then F28 must be 0

If one of these conditions is not met then a message box would appear
and cancel printing.

Any help or reference material is appreciated. Thanks!


--
shikamikamoomoo
------------------------------------------------------------------------
shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018
View this thread: http://www.excelforum.com/showthread...hreadid=472205


Bernie Deitrick

Check for value before printing...
 
shikamikamoomoo,

Put the code below into the codemodule of the Thisworkbook object. Change the sheet name to reflect
the sheet on which you want to base your control of printing.

HTH,
Bernie
MS Excel MVP

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim sh As Worksheet
Set sh = Worksheets("Sheet1")

With sh
If Not (IIf(sh.Range("D17").Value 0, _
IIf(sh.Range("D28").Value 0, True, False), True) And _
(IIf(sh.Range("F17").Value 0, _
IIf(sh.Range("F28").Value 0, True, False), True))) Then
MsgBox "You can't print until they're all greater than zero....."
Cancel = True
Exit Sub
End If
End With
End Sub


"shikamikamoomoo" <shikamikamoomoo.1w6u6e_1128110730.1072@excelfor um-nospam.com wrote in message
news:shikamikamoomoo.1w6u6e_1128110730.1072@excelf orum-nospam.com...

I am looking for a code that will do the following:

Before printing look for...

If D17 0 then D28 must be 0 AND
If F17 0 then F28 must be 0

If one of these conditions is not met then a message box would appear
and cancel printing.

Any help or reference material is appreciated. Thanks!


--
shikamikamoomoo
------------------------------------------------------------------------
shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018
View this thread: http://www.excelforum.com/showthread...hreadid=472205




shikamikamoomoo[_6_]

Check for value before printing...
 

Thanks worked great.


--
shikamikamoomoo
------------------------------------------------------------------------
shikamikamoomoo's Profile: http://www.excelforum.com/member.php...o&userid=21018
View this thread: http://www.excelforum.com/showthread...hreadid=472205



All times are GMT +1. The time now is 03:29 PM.

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