Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Can anyone help please.
I have a workbook that records overtime and the code behind a button on the sheet is used to start a new 28 day period. It unprotects the sheet, stores the carried forward amount, clears all the entries, enters new dates and pastes in the stored carry forward amount and finally re-protects the sheet. It all works fine except that many of our users make a habit of unprotecting the sheet and entering values over the top of functions and then complain next month that the workbook is broken! I want to password protect the sheet but that breaks my code. Is there a way to include a password in the VB code? TIA - GA |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Is there a way to include a password in the VB code?
Yes, there is. I've recently done something similar myself. First, I defined a global variable in this way: gv_Pwd = "XXX" where the XXX is the password with which the sheet is protected. After that, you can unprotect and protect the sheet using commands like this: ActiveSheet.Unprotect (gv_Pwd) ActiveSheet.Protect (gv_Pwd) Keep in mind to also protect the VB code (select the the project in the menu, right-click it and go to "VBAProject Properties". Under the protection tab, you can lock the code from viewing by unauthorized people. Otherwise people could snatch the password for the worksheet from the VB code itself ;). |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Su
Worksheets("xyz").Unprotect (PW) Worksheets("xyz").Protect (PW) Or Activesheet.Unprotect (PW) ActiveSheet.Protect (PW) Or from the main menu: Tools--Protection--Protect sheet Hans |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
flummi wrote:
Su Worksheets("xyz").Unprotect (PW) Worksheets("xyz").Protect (PW) Or Activesheet.Unprotect (PW) ActiveSheet.Protect (PW) Or from the main menu: Tools--Protection--Protect sheet Hans Vielen Dank Hans, Why is it that you always find the answer just after you've posted rather than just before 8^) Just to add to your post - I found that I had to use double quotes in the password e.g. Worksheet.Unprotect ("PW") GA |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
<Vielen Dank Hans,
< <Why is it that you always find the answer just after you've posted rather <than just before 8^) < < <Just to add to your post - I found that I had to use double quotes in the <password e.g. <Worksheet.Unprotect ("PW") < Hi GA, I'm not sure that I quite understand what you mean by "Why is it that ....." Did I find an answer AFTER I posted? Or are you referring to something else? Thanks for the clarification. It may be that I did not need quotes because I used a numeric password. Hans Ps: How come you speak German? :-) |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On 22 Mar 2006 05:38:29 -0800, "flummi" wrote:
[snip] I'm not sure that I quite understand what you mean by "Why is it that ...." Did I find an answer AFTER I posted? Or are you referring to something else? Thanks for the clarification. It may be that I did not need quotes because I used a numeric password. Hans Ps: How come you speak German? :-) I was talking about myself there Hans - just after I posted, I found the answer myself - almost as soon as I'd clicked submit. I meant why do I always find the answer just after I have actually posted rather than just before. Ps: Meine Mutter war Deutsch :^) Thanks again, GA |
#7
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Funny, how ambiguous language can be. :-)
You are most welcome, George. Und viele Gruesse aus dem kalten Deutschland! Hans |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Very Novice Excel user with security question | Excel Discussion (Misc queries) | |||
Worksheet Protection | Excel Discussion (Misc queries) | |||
VLOOKUP for Zip Code Ranges | Excel Worksheet Functions | |||
Using other workbooks.. | Excel Worksheet Functions | |||
password protect vba code | Excel Discussion (Misc queries) |