You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I'm not sure if you want to do this from code or from Excel but as this is a VBA forum lets assume it is code. In that case select the cell tou want to lock and the following 2 lines of code should do the trick
If you want to do it from Excel just lock the cell using the menu Format|Cells... then select the Protection tab and ensure the Locked tickbox is checked. Then use the Tools|Protection|Protect Sheet... menu to protect the sheet and any locked cells will be locked against alteration.