Do not allow printing untill required cells are complete

adupuy

New Member
Joined
Mar 18, 2009
Messages
2
I'm working on a workbook with two work sheets. I want on sheet two range ("t3") to be required before user can print sheet two. I want users to be able to print sheet one even if the required cell is blank in sheet two. below is the code i have entered that keeps users from printing both sheets untill required cell is filled in.

Private Sub Workbook_beforeprint(Cancel As Boolean)
If Sheet2.Range("t3") = "" Then
MsgBox "Must Enter Mileage"
Cancel = True
End If

End Sub

Please help..
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hello and welcome to MrExcel.

Try

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then Exit Sub
If Sheet2.Range("T3").Value = "" Then
    MsgBox "Must Enter Mileage"
    Cancel = True
End If
End Sub
 
Upvote 0
Awesome!! Thanks alot, I was on the right track trying to use the active sheet code but could not seem to get it right...
 
Upvote 0
Adupuy

Your code should work, where you having problems with it?

VoG

Won't that stop sheet 1 from ever being printed?:)
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top