Vba Lock sheet while still able to select cells

whcmelvin

Board Regular
Joined
Jul 27, 2011
Messages
82
Hi, I have a sheets with Order ID. I want to lock the sheets while still able to select the cells as the cells have some macro attached to it. Besides that, it is possible to still enter information into the protected sheets cells using vba codes? e.g Cells(1,1).value = "123"
If possible how does i do it? Thanks
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try like this

Code:
ActiveSheet.Unprotect Password:="abc"
Cells(1, 1).Value = "123"
ActiveSheet.Protect Password:="abc"
 
Upvote 0
That is one of the options that should appear when you protect the sheet manually.
 
Upvote 0
Try like this

Code:
    ActiveSheet.Protect Password:="abc", DrawingObjects:=True, Contents:=True, Scenarios:=True
 
Upvote 0
Try like this - obviously change the range to suit

Code:
With ActiveSheet
    .Range("A10,B15,C11,D12,K1").Locked = False
    .Protect Password:="abc", DrawingObjects:=True, Contents:=True, Scenarios:=True
End With
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,850
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top