Edit Locked Cells with UserForm only

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.
 
L

Libby

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
 

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

Top