+ Reply to Thread
Results 1 to 6 of 6

Locking WS getting Run-time error 1004 Unable to set locked property of the range class

  1. #1
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Locking WS getting Run-time error 1004 Unable to set locked property of the range class

    Hi, this code was working, then for some reason it faults out at line 90 and I am using "UserInterfaceOnly:=True". I am puzzled why it quit working. Any help is appreciated

    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,941

    Re: Locking WS getting Run-time error 1004 Unable to set locked property of the range clas

    I can think of a couple of things that could cause this, but without your file I don't know what did cause it.

    You do not show the code that calls Protect. You may be doing UserInterfaceOnly:=True in one place but without it in another. Hard to say without seeing all of your code. You have a comment that says, "'Save the workbook after protecting" but there is no protection in sight.

    If a user unprotects the sheet then reprotects it, UserInterfaceOnly:=True is no longer in force.

  3. #3
    Valued Forum Contributor
    Join Date
    09-30-2018
    Location
    Vlaams Brabant Belgium
    MS-Off Ver
    365
    Posts
    456

    Re: Locking WS getting Run-time error 1004 Unable to set locked property of the range clas

    Hi

    it seems you try to re-protect worksheets that already are protected

    the sheet in the workbook called ("Outgoing") is already protected with a password "DjS"

    so the code cant do 'Ws.Cells.Locked = True' because its already locked

    i think thats what is giving you trouble

    you might need to exclude the sheets you already lock with a password
    Please be as complete as possible in your asking so it may save use all the time to rework the solution because you didn't give all the requirements. If you have a layout in mind please work it out first so we can adapt our solution to it. Thanks.
    If you have been helped, maybe you could click the *

  4. #4
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Locking WS getting Run-time error 1004 Unable to set locked property of the range clas

    Thanks for the replies. Oddly this code does work, but the results isn't correct as it locks the wrong workbook, but it's doesn't fault.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    08-22-2009
    Location
    Manitoba
    MS-Off Ver
    Office 2010
    Posts
    524

    Re: Locking WS getting Run-time error 1004 Unable to set locked property of the range clas

    Well that was yet another Saturday brain fart. All I had to do was unprotect, lock, then protect each sheet and it worked!

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,941

    Re: Locking WS getting Run-time error 1004 Unable to set locked property of the range clas

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking on the star icon addreputationiconsmall.jpg below their name.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Run time error 1004 - Unable to set the hidden property of the range class
    By excelconditional in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2018, 12:09 PM
  2. Run-time error '1004'; Unable to set the Locked property of the Range class
    By haridevadiga in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2015, 07:30 AM
  3. Run-time error'1004': Unable to get the Interior property of the Range class
    By Kwame001 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-06-2013, 11:17 AM
  4. [SOLVED] Run-time error '1004' Unable to set the Locked Property of the Range Class
    By medakiva in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-09-2013, 09:13 AM
  5. [SOLVED] Run time error 1004: Unable to set hidden property of range class
    By SAVIOBLUEFOX in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-06-2013, 10:38 AM
  6. Run-time error '1004' Unable to set the Locked Property of the Range Class
    By Jerums in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-04-2013, 04:22 PM
  7. Run-time error 1004: Unable to set the hidden property of the Range class.
    By seabee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2011, 05:09 PM

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