So, you could create a table for your numeric masterpiece, select the table, and then choose Arrange -> Lock. Adobe photoshop old version for mac. Your work would be safe until someone chooses to unlock the table. Here is a sample: Sub LockCellsInNamedRange() ' Lock the cells of a named range in Excel vba '-- Const csRANGE_NAME As String = 'RangeToBeLock' With ActiveWorkbook.Worksheets('Sheet1').Range(csRANGE_NAME) 'Lock Cells in specified range.Locked = True 'Adjust protect categories as you need.Parent.Protect _ DrawingObjects:=True, _ Contents:=True, _ Scenarios:=True 'Enable Selection for Unlocked Cells only.Parent.EnableSelection = xlUnlockedCells '. Or Enable Selection for ALL cells on worksheet.Parent.EnableSelection = xlNoRestrictions End With End Sub Hope will help. Regards Andrija Vrcan. Do we need ti protect the sheet to lock the cells. Yes, we need to protect cells and corresponding worksheet. Record macro and everything will be clear. Note: If you want access to protected sheet via VBA code, you first need to unprotect it, eg. ActiveSheet.Unprotect or ThisWorkbook.Worksheets('Sheet1').Unprotect 'Referenced by Name or ThisWorkbook.Worksheets(1).Unprotect 'Referenced by Index or, if protected with password: Sub TestProtectUnprotect() Const csPASSWORD As String = 'my password' 'Protect sheet ActiveSheet.Protect Password:=csPASSWORD 'Unprotect sheet ActiveSheet.Unprotect Password:=csPASSWORD End Sub Andrija. Actually my requirement is I want to lock the cells of a named range after data is populated in to that range from database on a button click. User should not able to edit that range after data population is done in that range. Next, If I protect the sheet say sheet1,I want to some of the ranges in that sheet should be editable such that user can edit that range. Can you please help me how to proceed in this scenario. Thanks in Advance. Thanks and Regards, Shravan Arram From: Andrijaxl via visualbasic-l [mailto:[email protected]] Sent: Tuesday, January 05, 2010 8:21 PM To: Shravan Arram Subject: RE: [visualbasic-l] How to lock the cells of a named range in Excel vba [cid:[email protected]] Posted by Andrijaxl (graduated engineer of the chemical tehnology) on Jan 5 at 9:36 AM [cid:~WRD000.jpg]Mark as helpful Yes, we need to protect cells and corresponding worksheet. Record macro and everything will be clear. Note: If you want access to protected sheet via VBA code, you first need to unprotect it, eg. ActiveSheet.Unprotect or ThisWorkbook.Worksheets('Sheet1').Unprotect 'Referenced by Name or ThisWorkbook.Worksheets(1).Unprotect 'Referenced by Index or, if protected with password: Sub TestProtectUnprotect() Const csPASSWORD As String = 'my password' 'Protect sheet ActiveSheet.Protect Password:=csPASSWORD 'Unprotect sheet ActiveSheet.Unprotect Password:=csPASSWORD End Sub Andrija. Hi, I haven't been following this, as I am not the world's expert on Excel. But I do have a thought.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |