Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 1004 - Unable to set Unlock Property of Range Class 1

Status
Not open for further replies.

WalkerEvans

Technical User
Jan 17, 2007
171
US

I password protect everything built for general use around here; it keeps inquisitive fingers out of my formulas and confines entries to only those places where data should be entered. I'm now working on an Excel project which requires that a small range of cells be protected until all of the other data has been entered. This seems to require the use of the "LOCKED" property, which I have never needed before, so I've spent a lot of time in the Help file while building my code

The problem is that I get the above error, even though my code compiles and is in accord with the syntax in the Help file. Here is the code:

Code:
Sub DoSegs()
Application.Goto reference:=Range("j5")
ActiveWorkbook.Unprotect (****)
[highlight #FF99FF]Worksheets("name").Range("j5:j14").Locked = False[/highlight]
ActiveWorkbook.Protect (****)
...  code continues

The error occurs on the highlighted line. I've tried every variation I can think of to no avail. Can anyone see what is causing this?

----------------------------------------------------------------------------------
[small][ponder]"Did you hear about the guy who refused to pay his exorcist?[/small]
He was re-Possessed." [lol]
 





Hi,

You must unprotect the SHEET, assuming that the SHEET is protected, then make the change, the protect the sheet.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a brand NUANCE![tongue][/sub]
 
Skip,

That works perfectly. I knew it had to be something simple that was being overlooked.

Thanks! Have a purple-pointy on me! *
[thumbsup]

----------------------------------------------------------------------------------
[small][ponder]"Did you hear about the guy who refused to pay his exorcist?[/small]
He was re-Possessed." [lol]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top