How do I lock and unlock cells?

AChimpNamedCornelius

Board Regular
Joined
Aug 22, 2002
Messages
91
application.Worksheets("MyWorksheet").Range("A1", "R7").Locked = True

seems to not bomb at least, but I can still edit the cells. I go to Tools->Protection and protect the sheet, but then all cells are uneditable, not just the ones I want.

How do I make things like column headers, etc. unchangeable while still allowing the editing of the other cells?

I need to do this via code at startup to take care of people unlocking them by accident. In a similar post, the one response suggested recording a macro, locking a cell, then checking out what the macro recorded. That did nothing for me as the macro record button is grayed out.
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Cells are locked by default, but the locking has no effect unless the sheet is protected.

So you need to unlock the cells you want the user to be able to edit then protect the sheet.
 
Upvote 0

Forum statistics

Threads
1,219,162
Messages
6,146,660
Members
450,706
Latest member
LGVBPP

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