NOOB: Can someone write me some code?

C

cfleming

I need a code that will prevent printing or saving nless all fields
are filled in.

Thanks!
 
R

Rick Rothstein

All what fields? Cells on a spreadsheet (if so, which ones)? TextBoxes on a
UserForm (how many)? Something else (describe what)?
 
S

ShaneDevenshire

Hi,

You need to add the code to the Workbook_BeforePrint event and the
Workbook_BeforeSave event.

The interior code would be the same:
IF Range("A1")="" then
msgbox "Data is missing from cell A1."
Cancel=True
end if

You would need to add this for all the ranges that might be missing data, if
those ranges are contigious, for example A1:A100 then

For Each cell in Range("A1:A100")
If cell="" Then
Beep
MsgBox "whatever message you want here."
Cancel=True
Exit For
End if
Next cell
 
Å

尹庆超

use the follow events,add some judge codes
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

End Sub

Private Sub Workbook_BeforePrint(Cancel As Boolean)

End Sub
 
Top