Error: Cannot Set Range Class Property

2

2hOt

I've been trying to Get Excel to Change Worksheet Protection Passwor
using the -Locked Property -without success.

THIS IS THE SITUATION

*1.* I had the properties (format) of specific ranges set t
'Unlocked'
*2.* I then protected the Worksheet containing those ranges with
password
*3.* I now tried to unlock the Worksheet and set those specific cell
to 'locked' *programmatically*
e.g

Code
-------------------
worksheet(1).Unprotect('the password')
worksheets(1).range("X11:Y34").locked = Fals
-------------------

where range("X11:Y34") represents the specific unlocked cells

RESULT
I get and Error Message:
Run-time Error 1004. Could not set Range Class property.

What did I do wrong
 
P

paul.robinson

Hi
you shouldn't have parenthesis on the unprotect:

Worksheets(1).Unprotect Password:="My Password"

The locked stuff looks OK.
regards
Paul
 
I

ImpulseBlue

The parentheses do not matter, its just a shortcut way since the only
argument Unprotect requires is the password. I copied and ran your
code exactly, with the exception of worksheet(1) should be
worksheets(1)... it ran fine for me. I think your problem might be
somewhere else.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top