Message Box Warning

T

Tio Pepe

I want to write a macro that will show a warning message box when the user
filling out a form, created in Excel 2003 as a template, trys to close or
save the form without modifying the contents of a particular cell that
contains text that states that "You must enter a reason in this area"
 
J

Jacob Skaria

Hi Tio

Open workbook template. Launch VBE and paste the below code within the
"ThisWorkbook" object. Post back for any help..Thanks

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

'Here Range("A1") is assumed as mandatory and Range("A2") the comment field
If Trim(Range("A2")) <> "" And Trim(Range("A2")) = "You must enter a reason
in this area" Then
MsgBox "Please fill the comments", vbInformation, "Form name"
Cancel = True
End If
End Sub


If this post helps click Yes
 

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

Top