Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Error locking cell

Hi,

I receive the following error when trying to lock a cell via a macro -
"Unable to set the Locked Property of the Range class.". My code basically
writes a value into an unlocked cell, unprotects the sheet, changes the cell
to locked, then re-protects the sheet. Code is below:

Range("O73").Select
ActiveCell.FormulaR1C1 = "CHECKED"
ActiveSheet.Unprotect Password:="ABC"
Selection.Locked = True
ActiveSheet.Protect Password:="ABC"

The error occurs at "Selection.Locked" stage. Can anyone help me?????

Thanks,
Richard.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Error locking cell

Richard,

I've just tried your code in a command button and it worked ok, no probs.
Where are you running the code from?

"RSimp321" wrote:

Hi,

I receive the following error when trying to lock a cell via a macro -
"Unable to set the Locked Property of the Range class.". My code basically
writes a value into an unlocked cell, unprotects the sheet, changes the cell
to locked, then re-protects the sheet. Code is below:

Range("O73").Select
ActiveCell.FormulaR1C1 = "CHECKED"
ActiveSheet.Unprotect Password:="ABC"
Selection.Locked = True
ActiveSheet.Protect Password:="ABC"

The error occurs at "Selection.Locked" stage. Can anyone help me?????

Thanks,
Richard.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Error locking cell

I'm running the code from an excel add-in. The sheet seems to protect and
unprotect fine, but it just fails to lock the cell.

"Dean" wrote:

Richard,

I've just tried your code in a command button and it worked ok, no probs.
Where are you running the code from?

"RSimp321" wrote:

Hi,

I receive the following error when trying to lock a cell via a macro -
"Unable to set the Locked Property of the Range class.". My code basically
writes a value into an unlocked cell, unprotects the sheet, changes the cell
to locked, then re-protects the sheet. Code is below:

Range("O73").Select
ActiveCell.FormulaR1C1 = "CHECKED"
ActiveSheet.Unprotect Password:="ABC"
Selection.Locked = True
ActiveSheet.Protect Password:="ABC"

The error occurs at "Selection.Locked" stage. Can anyone help me?????

Thanks,
Richard.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Error locking cell

Only a suggestion but try re-selecting the cell before locking

"RSimp321" wrote:

I'm running the code from an excel add-in. The sheet seems to protect and
unprotect fine, but it just fails to lock the cell.

"Dean" wrote:

Richard,

I've just tried your code in a command button and it worked ok, no probs.
Where are you running the code from?

"RSimp321" wrote:

Hi,

I receive the following error when trying to lock a cell via a macro -
"Unable to set the Locked Property of the Range class.". My code basically
writes a value into an unlocked cell, unprotects the sheet, changes the cell
to locked, then re-protects the sheet. Code is below:

Range("O73").Select
ActiveCell.FormulaR1C1 = "CHECKED"
ActiveSheet.Unprotect Password:="ABC"
Selection.Locked = True
ActiveSheet.Protect Password:="ABC"

The error occurs at "Selection.Locked" stage. Can anyone help me?????

Thanks,
Richard.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Error locking cell

Only a suggestion? Only the answer to the problem I've been having all
morning! Thanks very much.

Richard.

"Dean" wrote:

Only a suggestion but try re-selecting the cell before locking

"RSimp321" wrote:

I'm running the code from an excel add-in. The sheet seems to protect and
unprotect fine, but it just fails to lock the cell.

"Dean" wrote:

Richard,

I've just tried your code in a command button and it worked ok, no probs.
Where are you running the code from?

"RSimp321" wrote:

Hi,

I receive the following error when trying to lock a cell via a macro -
"Unable to set the Locked Property of the Range class.". My code basically
writes a value into an unlocked cell, unprotects the sheet, changes the cell
to locked, then re-protects the sheet. Code is below:

Range("O73").Select
ActiveCell.FormulaR1C1 = "CHECKED"
ActiveSheet.Unprotect Password:="ABC"
Selection.Locked = True
ActiveSheet.Protect Password:="ABC"

The error occurs at "Selection.Locked" stage. Can anyone help me?????

Thanks,
Richard.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Locking Cell Ridhi Excel Worksheet Functions 1 June 6th 08 02:12 PM
Locking cell whatzzup Excel Discussion (Misc queries) 2 November 1st 07 08:16 PM
locking only one cell AJB Excel Discussion (Misc queries) 2 August 17th 07 09:40 AM
locking formula in cells in without locking whole sheet SuziQ Excel Discussion (Misc queries) 1 July 21st 06 03:58 PM
cell locking via VBA aken Excel Programming 3 June 20th 05 02:00 PM


All times are GMT +1. The time now is 09:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"