How is that different than what I have?
Main Topics
Browse All TopicsI have an Excel form that is being emailed to different parties to complete various parts of the form. I would like to unlock the appropriate cells for each group and unlock all others. I am using code like the following:
Call Worksheets("sheet1").Unpro
Worksheets("sheet1").Range
When this runs I get runtime Error 1004: Unprotect method of worksheet object failed. Sometimes I also get an error about the locked property being unavailable.
Any ideas as to why I can not programatically unprotect the spreadsheet?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I've tested the cells locked value before altering it and I can't understand why it can't set the lock. Does the location of the method call have any affect on it? i.e. if I call if from within the worksheet object or the workbook object? Is there any global property setting that may be giving me these errors? ProtectionMode?
I should also mention that I'm using Excel 97.
rthomsen,
The following sub works for me in Excel 97. I missed the fact that your password was in a named range on Sheet2 in my first post.
Sub ProtectRange()
Worksheets("Sheet1").Unpro
Range("A1:A10").Locked = True
Worksheets("Sheet1").Prote
End Sub
Brad
rthomsen,
I stored the sub in a regular module sheet. The sub worked on both the same workbook that contained Sheet1 and Sheet2, as well as Sheet1 and Sheet 2 in a different workbook.
The sub below uses a named range reqNum in cells A1:A10. Once again, Excel 97 ran perfectly.
Sub ProtectRange()
Worksheets("Sheet1").Unpro
Range("reqNum").Locked = True
Worksheets("Sheet1").Prote
End Sub
Brad
I found out why I'm getting the error and now I'm looking for a workaround. The problem is not that it is a named cell but rather that it is a merged cell.
When I use a merged cell and try to refer to as $A$1 the locked property fails. if I try to refer to the name by the actual range of merged cells I cannot retrieve the single value from it.
Any ideas?
Business Accounts
Answer for Membership
by: byundtPosted on 2003-12-04 at 08:12:26ID: 9875358
Hi rthomsen,
tect ("A1:A10") .Locked = True ct
You unprotect a worksheet & lock cells like this:
Sub test()
Worksheets("Sheet1").Unpro
Worksheets("Sheet1").Range
Worksheets("Sheet1").Prote
End Sub
Cheers!
Brad