PDA

View Full Version : Solved: VBA write to a protected cell and I have the password



sparafucile1
11-12-2007, 10:39 AM
I want a checkbox click() sub to write a value to a cell. I got this part down pat an works just fine. But I want to write protect the sheet so the user doesn't fat-finger something and break the formula's that I so-carefully put together.

So, naturally I protected the sheet with a specific password. But now my checkbox click() events are locked out. Can I "enter" the password for my VBA commands somehow to allow them to work as normal?

I realize that a determined individual could snarf out the password and still be malicious. That's not what I'm trying to prevent. It's the user who accidentally overwrites a formula or some other value.

I want the checkboxes to control everything!!:yes

Thanks,
Jeff

JimmyTheHand
11-12-2007, 10:58 AM
Try this

ActiveWorkbook.Sheets("Sheet1").Unprotect "password"
Range("A1") = "hehehe"
ActiveWorkbook.Sheets("Sheet1").Protect "password"

Jimmy

sparafucile1
11-12-2007, 11:40 AM
That was it! Thanks for the quick and simple code to use!
:clap:

unmarkedhelicopter
11-12-2007, 03:49 PM
Alternatively you could look at this thread http://vbaexpress.com/forum/showthread.php?t=15826