Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I have a worksheet that I created that requires a lot of sorting and other
macros. However with the worksheet protected I can't perform the functions. I need the worksheet password protected so the user can't mess up the formulas. Therefore, I need to un-protect the worksheet, sort the rows and then re-protect the worksheet. I can do it if I give the user the password but then they can just un-protect it. Therefore I want to have the password in the macro so it is done automatically. Help! |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
FredH, something like this,
Const PW As String = "123" 'Change Password Here ActiveSheet.Unprotect Password:=PW 'you code here ActiveSheet.Protect Password:=PW And protect the VBA project so they can't see the password there, like this To protect the VBA project, from your workbook right-click the workbook's icon and pick View Code. This icon is at the top-left of the spreadsheet this will open the VBA editor, in Project Explorer right click on your workbook name, if you don't see it press CTRL + r to open the Project Explorer then select VBA project properties, protection, check lock project for viewing and set a password. Press Alt and Q to close this window and go back to your workbook and save and close the file. Be aware that this password can be broken by third party software "FredH" wrote in message ... I have a worksheet that I created that requires a lot of sorting and other macros. However with the worksheet protected I can't perform the functions. I need the worksheet password protected so the user can't mess up the formulas. Therefore, I need to un-protect the worksheet, sort the rows and then re-protect the worksheet. I can do it if I give the user the password but then they can just un-protect it. Therefore I want to have the password in the macro so it is done automatically. Help! |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() "Paul B" wrote: FredH, something like this, Const PW As String = "123" 'Change Password Here ActiveSheet.Unprotect Password:=PW 'you code here ActiveSheet.Protect Password:=PW And protect the VBA project so they can't see the password there, like this To protect the VBA project, from your workbook right-click the workbook's icon and pick View Code. This icon is at the top-left of the spreadsheet this will open the VBA editor, in Project Explorer right click on your workbook name, if you don't see it press CTRL + r to open the Project Explorer then select VBA project properties, protection, check lock project for viewing and set a password. Press Alt and Q to close this window and go back to your workbook and save and close the file. Be aware that this password can be broken by third party software "FredH" wrote in message ... I have a worksheet that I created that requires a lot of sorting and other macros. However with the worksheet protected I can't perform the functions. I need the worksheet password protected so the user can't mess up the formulas. Therefore, I need to un-protect the worksheet, sort the rows and then re-protect the worksheet. I can do it if I give the user the password but then they can just un-protect it. Therefore I want to have the password in the macro so it is done automatically. Help! The following are my two macros. I don't have any sort codes in them. The protect macro puts the password test in but the unprotect macro doesn't work. |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() "Paul B" wrote: FredH, something like this, Const PW As String = "123" 'Change Password Here ActiveSheet.Unprotect Password:=PW 'you code here ActiveSheet.Protect Password:=PW And protect the VBA project so they can't see the password there, like this To protect the VBA project, from your workbook right-click the workbook's icon and pick View Code. This icon is at the top-left of the spreadsheet this will open the VBA editor, in Project Explorer right click on your workbook name, if you don't see it press CTRL + r to open the Project Explorer then select VBA project properties, protection, check lock project for viewing and set a password. Press Alt and Q to close this window and go back to your workbook and save and close the file. Be aware that this password can be broken by third party software "FredH" wrote in message ... I have a worksheet that I created that requires a lot of sorting and other macros. However with the worksheet protected I can't perform the functions. I need the worksheet password protected so the user can't mess up the formulas. Therefore, I need to un-protect the worksheet, sort the rows and then re-protect the worksheet. I can do it if I give the user the password but then they can just un-protect it. Therefore I want to have the password in the macro so it is done automatically. Help! Below are the macros i use. The protect macro works but the upprotect doesn'tSub Unprotect() ' ' Unprotect Macro ' Macro recorded 4/6/2007 by Charles Hord ' ' Keyboard Shortcut: Ctrl+u ' ActiveSheet.Unprotect Password:="test" Range("A2").Select Application.Run "'Macro test.xls'!Protect" End SubSub Protect() ' ' Protect Macro ' Protects sheet password is test ' ' ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="test" End Sub |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
It wasn't totally clear from the above but I had the same issue where the sub
unprotect wouldn't work. I realised it was because PW was only defined within "sub protect" but not within "sub unprotect". Fixed easily by defining PW within both subroutines. |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
One way:
Const csPWORD As String = "drowssap" ActiveWorkbook.Worksheets("Sheet1").Unprotect Password:=csPWORD 'Sort ActiveWorkbook.Worksheets("Sheet1").Protect Password:=csPWORD In article , FredH wrote: I have a worksheet that I created that requires a lot of sorting and other macros. However with the worksheet protected I can't perform the functions. I need the worksheet password protected so the user can't mess up the formulas. Therefore, I need to un-protect the worksheet, sort the rows and then re-protect the worksheet. I can do it if I give the user the password but then they can just un-protect it. Therefore I want to have the password in the macro so it is done automatically. Help! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to Protect OK, Unprotect now messed up! | Excel Worksheet Functions | |||
protect / unprotect VBA project by macro | Excel Discussion (Misc queries) | |||
Forgot the password (to unprotect a sheet) | Excel Discussion (Misc queries) | |||
is there anyway to make it so the users of my excel spread sheet cant view the macro code w/o a password? | Excel Worksheet Functions | |||
password protect vba code | Excel Discussion (Misc queries) |