Password for a group of cells


Posted by John on June 25, 2001 7:16 AM

Anyone come across a way to protect a single range of cells (i.e. A1 to C11) with a password.
Excel 97

Thanks

J.Timbray

Posted by Joe Was on June 25, 2001 7:25 AM

Note: This will only lock the whole sheet or lock, all the lock selected cells on a sheet. The trick is to un-check the "Lock cells" box for the cells you don't want the code to password lock.
Private Sub Worksheet_Change(ByVal Target As Range)
'
' Macro by Joseph S. Was
'
Application.EnableEvents = False

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="admin"
Application.EnableEvents = True

Hope this helps, JSW.

Anyone come across a way to protect a single range of cells (i.e. A1 to C11) with a password.



Posted by Peter on June 25, 2001 3:45 PM

Ty This

Hi,hope this will help, change the cell range in the macro to the ones you want.

Lock all cells except the ones you want to password protect(cells A1:A3, A5, B1:B2 in the code example below).


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).

Cheers,

Peter

Anyone come across a way to protect a single range of cells (i.e. A1 to C11) with a password.