protection against user update


Posted by rainy on August 02, 2001 4:19 AM

i have a report i made with vb code on excel,
and i want the users not to be able to change data on it or click any cell but the buttons i put there.
how can i do it?
i tried to add sheet protection but then i got error from the vb code saying its a read only sheet.



Posted by JAF on August 02, 2001 4:51 AM

What you'll need to do is keep the sheet protected, but add the following lines to your VB code:

Sub YourMacro()
ActiveSheet.Unprotect Password:="YOURPASSWORD"
'
'your existing code here
'
ActiveSheet.Protect Password:="YOURPASSWORD"

This will unprotect the sheet, run your code and then reprotect the sheet (if you don't want the password, just use ActiveSheet.Unprotect and ActiveSheet.Protect)

Good Luck

JAF