Saving Spreadsheets

Sergio_Montenegro

Board Regular
Joined
Feb 23, 2008
Messages
108
Hi folks, is there any way in which I can make sure that a spreadsheet cannot be saved unless specific cells have data or information entered...

For example if A1 has to have 100 entered and B2 has to have 200 entered, if I try and save it, I get a message that says "Some information is missing, please ensure all appropriate cells are competed correctly" or womething like that... I hope this makes sense.

Thanks in advance

Serge
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Paste into 'ThisWorkbook' module...

Change "Sheet1" to the name of the sheet in question...

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
    With Sheets("Sheet1")
        If .Range("A1") <> 100 Or .Range("B2") <> 200 Then
            MsgBox "Some information is missing, please ensure all appropriate cells are competed correctly", vbCritical, "Oops!!"
            Cancel = True
        End If
    End With
End Sub
 
Upvote 0
Also change the
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
to read
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

The above will fire when the user tries to print, not save....
 
Upvote 0
Well spotted - thanks for the correction!

Also change the
Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
to read
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

The above will fire when the user tries to print, not save....
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

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