ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Protect a Cell in an Editable Range (https://www.excelbanter.com/excel-programming/291692-protect-cell-editable-range.html)

GARY

Protect a Cell in an Editable Range
 
All

I have a spreadsheet as illustrated below:

A B
1 ab ef
2 gh
3 ij

that I have run the Sub below on:

Sub LockCells()

Range("A2", Cells.SpecialCells(xlLastCell)).Name
= "UsedCells"
ActiveSheet.Protection.AllowEditRanges.Add
Title:="Body", Range:=Range("UsedCells")
ActiveSheet.Protect "abc123",
DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub


What I am trying to do is lock an individual cell in a
named range where editing is allowed. i.e. after the
sheet is protected prevent editing on B2 and A3 as these
cells have no values. Any assistance would be
appreciated.

Thanks


Rob van Gelder[_4_]

Protect a Cell in an Editable Range
 
I don't have Excel XP here to try it, but maybe you could re-protect the
blank cells with something like:
Intersect(Range("UsedCells"), Cells.SpecialCells(xlCellTypeBlanks))


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Gary" wrote in message
...
All

I have a spreadsheet as illustrated below:

A B
1 ab ef
2 gh
3 ij

that I have run the Sub below on:

Sub LockCells()

Range("A2", Cells.SpecialCells(xlLastCell)).Name
= "UsedCells"
ActiveSheet.Protection.AllowEditRanges.Add
Title:="Body", Range:=Range("UsedCells")
ActiveSheet.Protect "abc123",
DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub


What I am trying to do is lock an individual cell in a
named range where editing is allowed. i.e. after the
sheet is protected prevent editing on B2 and A3 as these
cells have no values. Any assistance would be
appreciated.

Thanks





All times are GMT +1. The time now is 06:12 AM.

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