View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dwaine Horton[_3_] Dwaine Horton[_3_] is offline
external usenet poster
 
Posts: 21
Default Password Protect a single cell

Method two is the way I would like to go. I have done the steps but it is
not asking for a password. When I protect the sheet it doesn't even let me
go into that field. I do have Excel 2003. I believe method 1 will work but
I can't use any macros in this version as that will limit who can use the
form.

"Jay" wrote:

There are two methods you could use, Dwaine. I think Method 1 works best,
but you can be the judge.

Method 1:
-----------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Address = Range("A10").Address Then
pword = InputBox("Enter Password To Edit State:")
If pword = "Dwaine" Then ActiveCell.Select Else ActiveCell.Offset(1,
0).Select
End If
End Sub

Open your Excel workbook, switch to the VB Editor, select the Sheet object
that contains the cell you want to protect, and paste the above 6 lines of
code into the main work area window. Change the reference to cell €œA10€ in
line 2 to the address of the cell you want to protect and change €œDwaine€ in
the 4th line of code to what ever you want for a password. Save the
workbook; no other action is necessary.

Note that if the worksheet is to be protected for other reasons, the
"Locked" checkbox for the cell's Protection format must be cleared before
protecting the worksheet (this is counter-intuitive, but results in leaner
code and efficient execution (as opposed to adding more code to respond to
the sheet protection).

--------------------


Method 2:
--------------------
Alternatively, if you have Excel2003, try this:

Ensure that the Protection format of the single cell is set to "Locked" (use
Format, Cells, Protection, and check the Locked checkbox). Then, choose
"Tools, Protection, Allow Users to Edit Ranges..." Follow the instructions
there, adding a 'New' range that points to the single cell. Enter a password
for the cell. Don't monkey with the "Permissions..." button unless you are
in a networked environment with shared files.

This should work fine, too. The only problem is that once the cell is
unlocked with the password, it stays unlocked until the file is closed and
reopened.


Good luck and let me know if you have any trouble with this.

Jay