cell locking problem

N

navin

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
 
D

Doug Glancy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top