Protect spreadshet, but allow user edit range

S

Souris

I would like to protect my spreadsheet, but allow user a edit range.

I used following code:

Sheets(wsDestination).Select
ActiveSheet.Protection.AllowEditRanges(1).Delete
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.Protection.AllowEditRanges.Add Title:=wsDestination & " Range
", Range:=Range("G12:Q20")

If I have "ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True" first then the code failed on the last line. It makes sense,
because the spreadsheet already protected.

When I tried last line first, it protects all the spreadsheet.
If I do not uses "ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True" code, then the whole spreadsheet does not protect at all.

Are there anything wrong I did?

Any information is great appreciated,
 
R

Rowan

This works for me:

ActiveSheet.Protection.AllowEditRanges(1).Delete
ActiveSheet.Protection.AllowEditRanges.Add Title:=wsDestination _
& " Range", Range:=Range("D3:H12")
ActiveSheet.Protect DrawingObjects:=True, Contents:=True _
, Scenarios:=True

What is the value of wsDestination?

Regards
Rowan
 
S

Souris

Thanks it works now,

Thanks millions,

Rowan said:
This works for me:

ActiveSheet.Protection.AllowEditRanges(1).Delete
ActiveSheet.Protection.AllowEditRanges.Add Title:=wsDestination _
& " Range", Range:=Range("D3:H12")
ActiveSheet.Protect DrawingObjects:=True, Contents:=True _
, Scenarios:=True

What is the value of wsDestination?

Regards
Rowan
 

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