NOOB: Can someone write me some code?

  • Thread starter Thread starter cfleming
  • Start date Start date
C

cfleming

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

Thanks!
 
All what fields? Cells on a spreadsheet (if so, which ones)? TextBoxes on a
UserForm (how many)? Something else (describe what)?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top