navin,
With Activesheet
.Unprotect
.Range("J29").Locked = True
.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingColumns:=True,
AllowInsertingRows _
:=True, AllowInsertingHyperlinks:=True, AllowDeletingColumns:=True, _
AllowDeletingRows:=True, AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True
End With
hth,
Doug
"navin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have a sheet, in which i have to lock a single cell. i used the
> following code:
>
> ActiveSheet.Range("$J$29:$K$29").Select
> Range("$J$29:$K$29").Select
> ActiveSheet.Unprotect
> Selection.Locked = True
> Range("$J$29:$K$29").Select
> ActiveSheet.Protect DrawingObjects:=False, Contents:=True,
> Scenarios:= _
> False, AllowFormattingCells:=True,
> AllowFormattingColumns:=True, _
> AllowFormattingRows:=True, AllowInsertingColumns:=True,
> AllowInsertingRows _
> :=True, AllowInsertingHyperlinks:=True,
> AllowDeletingColumns:=True, _
> AllowDeletingRows:=True, AllowSorting:=True,
> AllowFiltering:=True, _
> AllowUsingPivotTables:=True
> ActiveSheet.EnableSelection = xlUnlockedCells
>
> above code locks the cell perfectly, but it also locks some of the cell
> below the locked cell ($J$29). Please help.
>
> thanks,
> navin
>
|