PDA

View Full Version : Noob with a (probably) simple one



3mustgetbeer
01-28-2011, 11:59 AM
Hi guys!

I'm new here so go easy :beg:

I have pretty much completed a spreadsheet with macros and need to (un)protect it before & after running the macros.

I have this
ActiveSheet.Unprotect Password:="abc123"

Which works fine, however I want to an options into the protection - for example I don't want the user to be able to select any locked cells.

Do you guys know what line this will take? - or prefereably some sort of glossary for the different options for protection?

Thanks for any replies :beerchug:

3MGB

Bob Phillips
01-28-2011, 12:20 PM
Lookup Worksheet.Protect in VBA help.

3mustgetbeer
01-28-2011, 12:54 PM
Cheers mate. Looked through and I now have

ActiveSheet.Protect Password:="abc123", _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
AllowFormattingCells:=True, _
AllowInsertingRows:=True, _
AllowDeletingRows:=True, _
AllowSorting:=True, _
AllowFiltering:=True

I can still select cells though? I thought the content part would mean I couldn't select any locked cells :banghead:

Bob Phillips
01-28-2011, 04:15 PM
Add thius



ActiveSheet.EnableSelection = xlUnlockedCells

3mustgetbeer
01-30-2011, 11:30 AM
xld

That works a treat, thanks alot for that mate!!