Edit Locked Cells with UserForm only

  • Thread starter Thread starter Benjamin
  • Start date Start date
B

Benjamin

I have three cells in worksheet that I want to remain locked on the worksheet.
And I only want the userform to allow these cells to be updates.
The ok button on the form updates these cells. But now it gives me this
error since the workbook is now locked:
Run-time error '1004'
I need to unlock it and lock it again.
need VBA code help here.
 
Hi Benjamin,

You can either specify that you want to allow programmatic changes when you
open the workbook.
Private Sub Workbook_Open()
Sheet1.Protect userinterfaceonly:=True
End Sub

or you can uprotect and reprotect your worksheet when you make the change

Private Sub Commandbutton1_Click()
sheet1.unprotect
'make changes
sheet1.protect
end sub
 
Back
Top