-
Any way to prevent users from saving the file?
Hi,
I am currently preparing my company's budget and would require a macro for my budget templates. I will actually need a macro to check a sum of ranges to make sure it is not above a certain amount.
For example
Row B12 - Total Staff Cost - Maximum cap = $50K
Row B15 - Total G&A Cost - Maximum cap = $10K
Is there a way to stop the user from saving the file if the amount they have keyed in the summary file exceeds the budget guideline given?
Thanks.. Your help will be greatly appreciated!
-
You could put your check in the BeforeSave Event of the workbook.
-
How do i place this BeforeSave Event ?
-
Like this.
[VBA]Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
With Sheets(1)
If .Range("B12") > 50000 Or .Range("B15") > 10000 Then
Cancel = True
MsgBox "Not saved - Limits exceeded", vbCritical
End If
End With
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules