save on condition
Hi Guye,
Try:
'=============
Private Sub Workbook_BeforeSave( _
ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim SH As Worksheet
Set SH = Me.Sheets("Sheet2") '<<=== CHANGE
With SH
If Not IsEmpty(.Range("E10")) Then
If IsEmpty(Range("F10")) Then
Cancel = True
MsgBox ("Your message")
End If
End If
End With
End Sub
'<<=============
This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:
Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.
---
Regards,
Norman
"Guye" wrote in message
oups.com...
hi all,
i need to creat an excel that prevent the user to save the file unless
he enters data on certain cells, for example
if the user enters data on cell E10 he must also enter data on cell
F10, if he doesnt do that he cant save the file and a msgbox appears
that ask him to enter the missing data.
|