ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   cell locking problem (https://www.excelbanter.com/excel-programming/381509-cell-locking-problem.html)

navin

cell locking problem
 
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


Doug Glancy[_7_]

cell locking problem
 
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" wrote in message
ps.com...
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





All times are GMT +1. The time now is 07:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com