Change the value of a protected cell

  • Thread starter Thread starter CoolCyber
  • Start date Start date
C

CoolCyber

hi,

I am trying to change the value of a cell that is protected. I do not want
the user to change the value, but change it using a macro. Aslo i want to
clear the value of a protected cell when the user clicks on a button.

thanks prn
 
Then what is the point of the protection? Why don't you just unprotect the
cell?? You could do this with a macro, but you'd need the password.
 
Worksheets("Sheet1").Unprotect(sheet password)
---the rest of your macro---
Worksheets("Sheet1").Protect(sheet password)

You can remove (sheet password) if the sheet is not password protected.
 
If you protect your sheet in code, you can allow your code to do things that
users can't.

Option Explicit
Sub auto_open()
With Worksheets("Sheet99")
.Protect Password:="Hi", userinterfaceonly:=True
End With
End Sub

It needs to be reset each time you open the workbook. (excel doesn't remember
it after closing the workbook. That's why I used auto_open/workbook_open.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top