Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Stop file being saved

Is there an code that would stop an excel file being saved if a certain
number was exceeded.
Example:- entering leave which exceeds the quota thus stoppping the user
saving the file.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Stop file being saved

hi
yes. but it would be nice to know which cell the leave is in and what the
quota is but in it's simplest form, it might look something like this.....
leave in A1. quota = 50
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Range("A1").Value 50 Then
MsgBox "leave exceeds quota. save not allowed"
Cancel = True
End If
End Sub

this is workbook code.
Alt+F11. in the project window(far left) expand the project(file). double
click "ThisWorkbook". paste above code into this workbook module.
modify if needed.

Regards
FSt1

"Jim Lavery" wrote:

Is there an code that would stop an excel file being saved if a certain
number was exceeded.
Example:- entering leave which exceeds the quota thus stoppping the user
saving the file.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Stop file being saved


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
With Worksheets("Sheet1").Range("A1")

If .Value < 5 Then
msgbobx "Value must be = 5"
Cancel = True
End If
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
__________________________________
HTH

Bob

"Jim Lavery" wrote in message
...
Is there an code that would stop an excel file being saved if a certain
number was exceeded.
Example:- entering leave which exceeds the quota thus stoppping the user
saving the file.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Stop file being saved

Brilliant, just what I wanted. thanks very much.

Jim
"FSt1" wrote in message
...
hi
yes. but it would be nice to know which cell the leave is in and what the
quota is but in it's simplest form, it might look something like this.....
leave in A1. quota = 50
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Range("A1").Value 50 Then
MsgBox "leave exceeds quota. save not allowed"
Cancel = True
End If
End Sub

this is workbook code.
Alt+F11. in the project window(far left) expand the project(file). double
click "ThisWorkbook". paste above code into this workbook module.
modify if needed.

Regards
FSt1

"Jim Lavery" wrote:

Is there an code that would stop an excel file being saved if a certain
number was exceeded.
Example:- entering leave which exceeds the quota thus stoppping the user
saving the file.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Stop file being saved

you're welcome
regards
FSt1

"Jim Lavery" wrote:

Brilliant, just what I wanted. thanks very much.

Jim
"FSt1" wrote in message
...
hi
yes. but it would be nice to know which cell the leave is in and what the
quota is but in it's simplest form, it might look something like this.....
leave in A1. quota = 50
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Range("A1").Value 50 Then
MsgBox "leave exceeds quota. save not allowed"
Cancel = True
End If
End Sub

this is workbook code.
Alt+F11. in the project window(far left) expand the project(file). double
click "ThisWorkbook". paste above code into this workbook module.
modify if needed.

Regards
FSt1

"Jim Lavery" wrote:

Is there an code that would stop an excel file being saved if a certain
number was exceeded.
Example:- entering leave which exceeds the quota thus stoppping the user
saving the file.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Number Format on Excel File saved from .html file joyfulone Excel Discussion (Misc queries) 3 April 15th 09 12:07 AM
Saved *.csv file gives SYLK file type warning upon Excel 2003 open Tom Excel Discussion (Misc queries) 5 March 19th 08 03:15 PM
How to tell number of spaces between values in saved text file fromthe original xls file [email protected] Excel Discussion (Misc queries) 1 January 15th 08 11:52 AM
Stop "Book1" from opening from a saved file jcutolo Excel Discussion (Misc queries) 4 July 27th 07 08:08 PM
How do I stop today() from updating date on saved spreadsheets? lionmark Excel Discussion (Misc queries) 2 January 4th 05 01:03 AM


All times are GMT +1. The time now is 09:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"