validation before exit or save

parajf

New Member
Joined
Nov 20, 2010
Messages
25
Dear all,

please please help for below requirement

I want excel not to save unless i have A1 = 2, that means i want validation for number 2 in A1 cell before saving, if A1 <> 2 then it will give message " Data not valid" , please... please help

regards
juzar para

00971504966280
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Try in the ThisWorkbook module

Rich (BB code):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheets("Sheet1").Range("A2").Value <> 2 Then
    Cancel = True
    MsgBox "Data not valid" & vbNewLine & "File NOT saved", vbExclamation
End If
End Sub

Change Sheet1 to the name of the sheet.
 
Upvote 0
Thank you friend,

It worked very fine, below is my mobile number,

regards

juzar para


Try in the ThisWorkbook module

Rich (BB code):
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Sheets("Sheet1").Range("A2").Value <> 2 Then
    Cancel = True
    MsgBox "Data not valid" & vbNewLine & "File NOT saved", vbExclamation
End If
End Sub

Change Sheet1 to the name of the sheet.
 
Upvote 0
Dear all,

I want to create more than three floating radio buttons on right side of excel sheet, it should be visible all the time and it should link me to different sheet or workbooks, I am not considering freeze

Regards

Juzar para
 
Upvote 0
You should really start a new thread for this completely different question.

Do you really need radio buttons? If you right click in the navigation arrows (bottom left) you will get a pop-up list of sheets.
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,801
Members
449,189
Latest member
kristinh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top