Good Morning,
I need to protect only some cells of a column, for example column H, from H16 to H 139 by a macro. Is there a little help.
Thanks
Good Morning,
I need to protect only some cells of a column, for example column H, from H16 to H 139 by a macro. Is there a little help.
Thanks
hi sasa, try this:
to unlock go to tools-> Protection->Unprotect sheet
[vba]
Sub x()
'
' Macro4 Macro
' Macro recorded 3/28/2009 by joms
'
'
Cells.Select
Selection.Locked = False
Selection.FormulaHidden = False
Range("h16:h139").Select
Selection.Locked = True
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
[/vba]
Last edited by joms; 03-28-2009 at 04:53 AM.
Tidying up Joms' code to get rid of these inefficient selections
[VBA]
Sub x()
With Cells
.Locked = False
.FormulaHidden = False
With .Range("h16:h139")
.Locked = True
.FormulaHidden = False
End With
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
thanks, mdmackillop... that code was just recorded... at i least i learn something from you...