Protect WorkSheet but change cell values via VB without password dialogue

Copper Contributor

I have a worksheet with macro control. Other than control, the whole sheet is "locked" and password protected. When clicking on the control, I want to change some values in the worksheet (via VB code) w/o the "supply password" dialogue box coming up - yet I don't want to put a line of code in the VB that "supplies" the password as that would make it to easy for users to view.

How can this be accomplished?

3 Replies
You can't have VBA code unprotect a sheet without the PW dialog and at the same time without including the password. But you can protect the VBA project so others cannot see the password. Would that help?

@JKPieterse  

Yes that would help... suggestion?

@INeedHelpSoon Sure, something like:

Sub ChangeSomething()
    ActiveSheet.Unprotect "PasswordGoesHere"
    Range("C3").Value = "Entry Into cell C3"
    ActiveSheet.Protect "PasswordGoesHere"
End Sub