vasim
Member
Hi,
I am using this vba, its working fine till the time save option button is clicked but when the users click on the Red cross button, save alert is displayed, I click NO the wb closes without saving, I click cancel, thats fine (I want this option), I click YES ("Thats were the problem is) the message box populates and again the save alert. How can I stop this.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Range("A1") <> Range("b1") Then
MsgBox "Not same"
Cancel = True
End If
End Sub
I am using this vba, its working fine till the time save option button is clicked but when the users click on the Red cross button, save alert is displayed, I click NO the wb closes without saving, I click cancel, thats fine (I want this option), I click YES ("Thats were the problem is) the message box populates and again the save alert. How can I stop this.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Range("A1") <> Range("b1") Then
MsgBox "Not same"
Cancel = True
End If
End Sub