ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sheet Protection and VBA Code (https://www.excelbanter.com/excel-discussion-misc-queries/28133-sheet-protection-vba-code.html)

TheRobsterUK

Sheet Protection and VBA Code
 

Does anyone know how to get Excel to allow VBA code to write to a
password protected worksheet?

I am using a work-around solution at the moment whereby the VBA
unprotects the relevant worksheet, writes data to it, then re-protects
it.

There must be a better way than this though. Obviously I don't want my
users to delete the formulas etc in the worksheet but I want my code to
be able to write data to the worksheet without having to
unprotect/re-protect it all the time!

Thanks
-Rob


--
TheRobsterUK


------------------------------------------------------------------------
TheRobsterUK's Profile: http://www.excelforum.com/member.php...fo&userid=9924
View this thread: http://www.excelforum.com/showthread...hreadid=374547


Jim Rech

One of the arguments of the Worksheet Protect method is UserInterfaceOnly.
You should protect the sheet in code, setting that to true and see if it
helps. It is not a setting that saves with the workbook so it has to be
reset after each open.

--
Jim
"TheRobsterUK"
wrote in message
news:TheRobsterUK.1pp4ac_1117206302.1348@excelforu m-nospam.com...
|
| Does anyone know how to get Excel to allow VBA code to write to a
| password protected worksheet?
|
| I am using a work-around solution at the moment whereby the VBA
| unprotects the relevant worksheet, writes data to it, then re-protects
| it.
|
| There must be a better way than this though. Obviously I don't want my
| users to delete the formulas etc in the worksheet but I want my code to
| be able to write data to the worksheet without having to
| unprotect/re-protect it all the time!
|
| Thanks
| -Rob
|
|
| --
| TheRobsterUK
|
|
| ------------------------------------------------------------------------
| TheRobsterUK's Profile:
http://www.excelforum.com/member.php...fo&userid=9924
| View this thread: http://www.excelforum.com/showthread...hreadid=374547
|




All times are GMT +1. The time now is 03:00 AM.

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