ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Edit Locked Cells with UserForm only (https://www.excelbanter.com/excel-programming/430985-edit-locked-cells-userform-only.html)

Benjamin

Edit Locked Cells with UserForm only
 
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.

Libby

Edit Locked Cells with UserForm only
 
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



"Benjamin" wrote:

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.



All times are GMT +1. The time now is 01:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com