fill in cell before printing / saving

K

Karissa

I have looked at previous posts and the codes given have not worked.

Is there a way to stop a user from printing an excel sheet before filling in
specific areas? If not I need help with the code associated with not saving
before filling it out. Help?
 
B

Bernard Liengme

Place this subroutine in a workbook module (not a general module)

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Range("Sheet3!C10") = "" Then
Cancel = True
MsgBox "No tax value entered into C10"
End If
End Sub

best wishes
 
K

Karissa

Ok, so this may be one of my issues: I am not sure the difference between
workbook module and general module. I have been putting the code in "This
workbook" and nothing happens. Any guidance?
 
O

Otto Moehrbach

You have the right module. What version of Excel are you using? What is
your macro security setting? Are you opening the file with macros enabled?
Are you sure that you had the ThisWorkbook module on the screen when you
pasted the macro into it? You must double-click "ThisWorkbook" to access
that module. HTH Otto
 
G

Gord Dibben

Right-click on the Excel Icon left of "File" or left end of Title Bar if
sheet window not maximized,

Select "View Code" and paste the code into that module............which is
Thisworkbook module.

Alt + q to return to Excel window.

Hit Print button.

If the range is empty or a formula returns "" the code should cancel the
print job and pop up the msgbox.


Gord Dibben MS Excel MVP
 
K

Karissa

I am using excel 2003 its on medium security

I keep getting a run time error : run time error'1004':method 'range'of
object_Global'failed.

otherwise all I did was cut and paste this code just to test it for sheet3:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Range("Sheet3!C10") = "" Then
Cancel = True
MsgBox "No tax value entered into C10"
End If
End Sub

I appreciate your help
 
K

Karissa

I figured it out...spaced the fact that I named the tabs and it was no longer
sheet3
dumb user mistake. Thank you for your help!!
 
Top