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
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,019
Messages
5,834,984
Members
430,331
Latest member
Syed Yasir Hannan

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top