C cfleming Oct 1, 2008 #1 I need a code that will prevent printing or saving nless all fields are filled in. Thanks!
R Rick Rothstein Oct 1, 2008 #2 All what fields? Cells on a spreadsheet (if so, which ones)? TextBoxes on a UserForm (how many)? Something else (describe what)?
All what fields? Cells on a spreadsheet (if so, which ones)? TextBoxes on a UserForm (how many)? Something else (describe what)?
S ShaneDevenshire Oct 1, 2008 #3 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
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
Š尹庆超 Oct 2, 2008 #4 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
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