+ Reply to Thread
Results 1 to 5 of 5

Error locking cell

  1. #1
    RSimp321
    Guest

    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. #2
    Dean
    Guest

    RE: 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. #3
    RSimp321
    Guest

    RE: 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. #4
    Dean
    Guest

    RE: 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. #5
    RSimp321
    Guest

    RE: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1