ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unlock protected worksheet (https://www.excelbanter.com/excel-programming/346082-unlock-protected-worksheet.html)

David

Unlock protected worksheet
 
I have sent 2006 Budget worksheets to all my franchises, who have entered
data already. I've added some features that I want them to use and want to
copy their data into the new worksheet. I also want to create macro that
writes a statement in a protected field. All the sheets are protected with a
password I do not want them to knowm but they do have access to certain cells
to enter their data.
When I send the new worksheet, I want to create a macro that copies their
data and then writes that the import is done.
How can I use the macro to unprotect a sheet, write the statement, protect
the sheet again, and make sure they do not have access to the password?

Jim Thomlinson[_4_]

Unlock protected worksheet
 
There is no absolutely foolproof way to ensure taht they can not get access
the the password. There are any number of code solutions to crack password.
That being said assuming the the users are not fiendish then yo just need to
lock the project int the VBE. Right click the project and select security.
check to hide the code and add a password. Here is some code for you...

Sub ImportData()
Dim wksCopyfrom as worksheet
dim wksCopyto as worksheet

set wskcopyfrom = sheets("Sheet1")
set wskcopyto = sheets("Sheet2")

wkscopyfrom.unprotect "MyPassword"
wkscopyto.unprotect "MyPassword"
wkscopyfrom.range("A1").copy wkscopyto.range("A1")
wkscopyfrom.protect "MyPassword"
wkscopyto.protect "MyPassword"

end Sub
--
HTH...

Jim Thomlinson


"David" wrote:

I have sent 2006 Budget worksheets to all my franchises, who have entered
data already. I've added some features that I want them to use and want to
copy their data into the new worksheet. I also want to create macro that
writes a statement in a protected field. All the sheets are protected with a
password I do not want them to knowm but they do have access to certain cells
to enter their data.
When I send the new worksheet, I want to create a macro that copies their
data and then writes that the import is done.
How can I use the macro to unprotect a sheet, write the statement, protect
the sheet again, and make sure they do not have access to the password?


dominicb[_168_]

Unlock protected worksheet
 

Good morning David

Alternatively this line will enable macros to write to protected cells
and users not to.

Activesheet.Protect UserInterfaceOnly=True

HTH

DominicB


--
dominicb
------------------------------------------------------------------------
dominicb's Profile: http://www.excelforum.com/member.php...o&userid=18932
View this thread: http://www.excelforum.com/showthread...hreadid=486609



All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com