View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default 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