Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
VBA
Hi All,
Is there a way I can enter a code in VBA that would protect my sheet if it had been unprotected for say 5 minutes. Just to make that a bit clearer I have a worksheet which is protected, I need the user to be able to unprotect the worksheet by using a button. (that's the easy bit). But then I would like the sheet to protect itself after 5 minutes Thanks in advance SPL |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
VBA
In the unprotect macro, you could add code to call an Ontime macro that will
protect it. If you also protect it using a button, you could add code in that macro to cancel the call. Something like Public nTime As Double Sub ProtectButtonCode() 'your code Application.OnTime nTime, "ProtectSheet", , False End Sub Sub UnprotectButtonCode() nTime = Now + TimeSerial(0, 5, 0) '5 minutes Application.OnTime nTime, "ProtectSheet" End Sub Sub ProtectSheet() ActiveSheet.Protect End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "PH NEWS" wrote in message ... Hi All, Is there a way I can enter a code in VBA that would protect my sheet if it had been unprotected for say 5 minutes. Just to make that a bit clearer I have a worksheet which is protected, I need the user to be able to unprotect the worksheet by using a button. (that's the easy bit). But then I would like the sheet to protect itself after 5 minutes Thanks in advance SPL |
#3
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
VBA
Thanks Bob, but that's a bit over my head. I can't decipher between what I
need and what I don't need. I don't protect the sheet with a button it is already protected. Could you tell me which part(s) of those codes I need if all I want the button to do is unprotect the sheet for five minutes. This would be a massive help. Thanks in advance SPL "Bob Phillips" wrote in message ... In the unprotect macro, you could add code to call an Ontime macro that will protect it. If you also protect it using a button, you could add code in that macro to cancel the call. Something like Public nTime As Double Sub ProtectButtonCode() 'your code Application.OnTime nTime, "ProtectSheet", , False End Sub Sub UnprotectButtonCode() nTime = Now + TimeSerial(0, 5, 0) '5 minutes Application.OnTime nTime, "ProtectSheet" End Sub Sub ProtectSheet() ActiveSheet.Protect End Sub -- HTH Bob Phillips (remove nothere from email address if mailing direct) "PH NEWS" wrote in message ... Hi All, Is there a way I can enter a code in VBA that would protect my sheet if it had been unprotected for say 5 minutes. Just to make that a bit clearer I have a worksheet which is protected, I need the user to be able to unprotect the worksheet by using a button. (that's the easy bit). But then I would like the sheet to protect itself after 5 minutes Thanks in advance SPL |
#4
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
VBA
"PH NEWS" wrote in message ... Thanks Bob, but that's a bit over my head. I can't decipher between what I need and what I don't need. I don't protect the sheet with a button it is already protected. I understand that, but when it gets unprotected (via your button) you want it protected again, so I was suggesting adding another button for that where you can add your specific code (as I showed). Could you tell me which part(s) of those codes I need if all I want the button to do is unprotect the sheet for five minutes. This would be a massive help. You could add this to your unprotect button code. Dim Time As Double nTime = Now + TimeSerial(0, 5, 0) '5 minutes Application.OnTime nTime, "ProtectSheet" and then just put this next macro into a standard code module. Sub ProtectSheet() ActiveSheet.Protect End Sub |
#5
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
VBA
Fantastic. Thanks for the explanation Bob, a massive help.
"Bob Phillips" wrote in message ... "PH NEWS" wrote in message ... Thanks Bob, but that's a bit over my head. I can't decipher between what I need and what I don't need. I don't protect the sheet with a button it is already protected. I understand that, but when it gets unprotected (via your button) you want it protected again, so I was suggesting adding another button for that where you can add your specific code (as I showed). Could you tell me which part(s) of those codes I need if all I want the button to do is unprotect the sheet for five minutes. This would be a massive help. You could add this to your unprotect button code. Dim Time As Double nTime = Now + TimeSerial(0, 5, 0) '5 minutes Application.OnTime nTime, "ProtectSheet" and then just put this next macro into a standard code module. Sub ProtectSheet() ActiveSheet.Protect End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|