ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   unlocking problem (https://www.excelbanter.com/excel-programming/353175-unlocking-problem.html)

dorre

unlocking problem
 
Hi

I have columns that are normally locked with protection on. But, I need to
have code that allows me to temporarily unluck column N. Why do I get an
error (1004: unable to set the locked property of the range class) with
this code?

Activesheet.Columns("N:N").Select
Selection.Locked = False

thanks
dorre



Tom Ogilvy

unlocking problem
 
I assume the sheet is protected, so you need to unprotect it to change the
locked property

Activesheet.Unprotect
ActiveSehet.Columns("N:N").Locked = False
Activesheet.Protect


If you are just trying to work with the cells using code, you might use the
interfaceonly property - only setable via code.

Activesheet.Protect UserInterfaceOnly:=True

This should avoid the need to unlock the cells. If you want to allow user
access, then see the first suggestion.


--
Regards,
Tom Ogilvy


"dorre" wrote in message
...
Hi

I have columns that are normally locked with protection on. But, I need

to
have code that allows me to temporarily unluck column N. Why do I get an
error (1004: unable to set the locked property of the range class) with
this code?

Activesheet.Columns("N:N").Select
Selection.Locked = False

thanks
dorre





ben

unlocking problem
 
try unlocking the worksheet first then relocking it

--
When you lose your mind, you free your life.
Ever Notice how we use '' for comments in our posts even if they aren''t
expected to go into the code?


"dorre" wrote:

Hi

I have columns that are normally locked with protection on. But, I need to
have code that allows me to temporarily unluck column N. Why do I get an
error (1004: unable to set the locked property of the range class) with
this code?

Activesheet.Columns("N:N").Select
Selection.Locked = False

thanks
dorre





All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com