andysando
andysando

Reputation: 1192

Protect cells in excel but should be able to copy them

If I use this code to protect a worksheet, how can I make it so that the user still can copy the cells? And can you specify certain cells that should NOT be protected, or at least the user should be able to edit them?

Worksheets("EKONOMI").Protect UserInterfaceOnly:=True

Upvotes: 2

Views: 1532

Answers (2)

SickDimension
SickDimension

Reputation: 912

You can define if user is allowed to select cells in protected sheet by using

Worksheets("EKONOMI").EnableSelection = xlNoRestrictions 'worksheet has to be protected for this to take effect

To make user able to edit certain cells you have to unlock the cells before the protection. For instance you can use the following to make Range C3 as unlocked cell

ActiveSheet.Range("C3").Select
Selection.Locked = False

Upvotes: 1

Snail
Snail

Reputation: 89

Sheets("EKONOMI").Activate ActiveSheet.Unprotect Password:="123" 'ActiveSheet.Protection.AllowEditRanges(1).Delete ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range("A1:A10") ActiveSheet.Protect Password:="123"

Please find the above code to protect sheet by allowing user to edit patricular range of cells.

ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range("A1:A10")

Mention the range name and range size for the user to edit.

Upvotes: 0

Related Questions