Editable ranges

hhammash

Board Regular
Joined
Jun 24, 2002
Messages
156
Hi,

How can I lock the whole spreadsheet and keep only the following range active:

C12 to H64

Is is possible to create more than one editable range and lock the rest of the spreadsheet?

Thanks
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Place in the sheet module you want this control in, like: Sheet1.

'Make cell always closed for changes even if protected!
If Target.Address = "$A$2" Then
Target.Offset(1, 0).Select
End If

'Make cell always open for changes even if protected!
If Target.Address = "$B$2" Then
ActiveSheet.Unprotect Password:="admin"
End If

'Keep sheet protected!
If Target.Address <> "$B$2" Then
ActiveSheet.Protect Password:="admin"
End If
End Sub
 

nbrcrunch

Well-known Member
Joined
Jan 1, 2003
Messages
2,062
Before locking the sheet:
Select the cells you wanted to remain editable.
Menu: Format - Cells
Format Cells pane: Click the Protection tab.
Uncheck locked for the selected cells.
 

hhammash

Board Regular
Joined
Jun 24, 2002
Messages
156
Hi,

Thank you
nbrcrunch for the codeless help and Joe Was for the coded one.

It is working.

Thanks a lot
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
This works for your posted Range, you can add any number of Ranges this way!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If ((Target.Row >= 12 And Target.Row <= 64) And _
(Target.Column >= 3 And Target.Column <= 8)) Then

ActiveSheet.Unprotect Password:="admin"
Else

ActiveSheet.Protect Password:="admin"

MsgBox "You can only edit cells in Range:" & vbLf & vbLf & _
"C12:H64" & vbLf & vbLf & " Your selection: " & Target.Address & _
vbLf & "is not in the Edit Range!"
End If
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,118,673
Messages
5,573,594
Members
412,537
Latest member
Mohamed_5966
Top