You have to format the individual cells you don't want to protect and then protect the whole sheet.
Christopher,
There is a way to 'password protect' a range of cells. I have created a working example, with macros & explanations. If you would like to review it, let me know via email and I will forward it to you.
Garland
Christopher
Can be done with VBA.
Lock all cells except the ones you want to password protect(cells A1:A3, A5, B1:B2 in the code example below).
Protect the worksheet.
Put the following in the sheet module.
(The password is "allow")
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pwRange As Range, check As String
Set pwRange = Range("A1:A3, A5, B1:B2")
If Not Intersect(Target, pwRange) Is Nothing Then
Application.EnableEvents = False
check = InputBox("Enter password")
If check <> "allow" Then
MsgBox "Password required"
On Error GoTo 1
Application.Undo
Application.EnableEvents = True
Exit Sub
End If
End If
1: Application.EnableEvents = True
End Sub
There were a couple of unnecessary lines in the code posted :-
Private Sub Worksheet_Change(ByVal Target As Range)
Dim pwRange As Range, check As String
Set pwRange = Range("A1:A3, A5, B1:B2")
If Not Intersect(Target, pwRange) Is Nothing Then
Application.EnableEvents = False
check = InputBox("Enter password")
If check <> "allow" Then
MsgBox "Password required"
On Error GoTo 1
Application.Undo
End If
End If
1: Application.EnableEvents = True
End Sub
Christopher
Please note that the above procedure does not prevent the password protected cells from being changed by dragging the contents from another cell.
To prevent this, a Worksheet_SelectionChange would also need to be added (but this would mean entering the password twice).
Celia
Of course, all this assumes your users do not know how to view the source code which contains the password!
Assuming you have a group of 'users' who you want to be able to view the contents of the file but make no changes and also a group of 'authorised users' who are able to modify some cells but are prevented from modifying all of them. Then the best way to achieve this is to do the following:
1) Set the 'Locked' property (Format>Cells>Protection>Locked) for all cells as required (Note that this doesn't actually lock the cells yet!) The default is 'locked' so you will just need to 'unlock' those cells which your authorised users will be able to change.
2) Protect the worksheet (Tool>Protection>Protect Sheet) with a password which only you will know. (This will allow you to modify any cell if required)
3) Save the workbook with a password for write access (File>SaveAs>Options>Password To Modify) This password will be the one you give to your 'authorised users' as it will give them the ability to modify the unlocked cells.
Phil