|
-
Feb 27th, 2004, 04:00 AM
#1
Thread Starter
Hyperactive Member
Protect only some cells on an Excel spreadsheet *RESOLVED*
Hi,
Is it possible to protect just certain cells on an Excel spreadsheet?
I need to prevent the user from accidentally entering data into certain columns unless they have entered a password.
I'm OK with the password entry bit.
The code I have so far is:
VB Code:
Private Sub cmdLockA_Click()
Sheet1.Range("A:A").Locked = True
Sheet1.Protect
End Sub
Private Sub cmdUnlockA_Click()
frmPasswordColumnA.Show
If sColumAPasswordEntered = "Sossij" Then
Sheet1.Unprotect
Sheet1.Range("A:A").Locked = False
End If
End Sub
The test code above is supposed to just prevent data entry to column A.
Unfortunately, it seems to protect the whole sheet.
Any help would be appreciated.
Last edited by Simon Caiger; Feb 27th, 2004 at 09:33 AM.
Simon Caiger
Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.
-
Feb 27th, 2004, 08:55 AM
#2
Addicted Member
I think you have missed the point that all cells in a worksheet are locked by default, so you first need to unlock them all, then lock your special cells.
Sheet1.Cells.Locked = False ..............
Regards
BrianB
-------------------------------
-
Feb 27th, 2004, 08:55 AM
#3
Junior Member
Hey there,
OK, all you need to do is unprotect your sheet. Select those cells you don't want protected, right click (or select from the menu) Format Cells.
The last tab should be protection. All cells are by default Locked. Simply uncheck the locked box for those cells you don't want locked. Then reprotect your sheet.
Peace!
Josh
-
Feb 27th, 2004, 09:33 AM
#4
Thread Starter
Hyperactive Member
Thanks for the replies,
I do VBA very infrequently as you probaly noticed.
I had missed the point that the cells are locked by default.
I ended up doing this a different way but I will go back and give it a try the proper way.
Simon Caiger
Documentation is like sex; when it's good, it's very, very good, and when it's bad, it's better than nothing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|