Reputation: 71
This is my problem. I need my VBA macro to make a particular number of top rows (let say, N) in an Excel spreadsheet read-only, so a user would not be able to change them by mistake. Still, I need a user to be able to edit and change other rows in the same spreadsheet. If I do something like
Range("A1:J10").Select
Selection.Locked = True
ActiveSheet.Protect Contents:=True
then the whole spreadsheet is getting locked. If, on the other hand, I omit ActiveSheet.Protect Contents:=True
line (do not protect the sheet), nothing is getting locked at all.
So, the question is: is it possible to block only the specified rows, while allowing user to edit the rest of them? I would appreciate the VBA code doing that.
Upvotes: 0
Views: 1297
Reputation: 166196
By default all cells on a sheet are Locked=True, but this has no effect until the sheet is protected.
You will need to unlock the cells you want to stay editable before the sheet is protected.
Upvotes: 2