Results 1 to 5 of 5

VBA error - Unble to set the Locked property of the Range class

Threaded View

Libster78 VBA error - Unble to set the... 01-25-2010, 05:31 PM
romperstomper Re: VBA error - Unble to set... 01-25-2010, 05:51 PM
Leith Ross Re: VBA error - Unble to set... 01-25-2010, 05:53 PM
Libster78 Solved! VBA error - Unble to... 01-25-2010, 06:14 PM
upsipo Re: VBA error - Unble to set... 03-01-2013, 04:16 PM
  1. #1
    Forum Contributor
    Join Date
    01-21-2010
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    105

    VBA error - Unble to set the Locked property of the Range class

    Hi all,

    I am having trouble with a macro for unprotecting a sheet keeping specific cells locked then clearing contents of other cells then reproect the sheet.

    I wrote one for one sheet which works and I have re used this but it keeps saying Unable to set the Locked property of the Range class.

    Can anyone see what I've done wrong?

    Sub AllNew()
           With Sheet7
            .Unprotect
           Cells.Locked = False
            [A13:J13, J14:J53, I54:J56, I1:J3].Locked = True
            [A14:I53].ClearContents
            [B9].Select
             .Protect
        End With
    End Sub
    The code that worked is:
    Sub NewInvoice()
    
        With Sheet1
            .Unprotect
            Cells.Locked = False
            [A19:J19, I1:J3, I43:J45, I50:I54, B50:B54, B10:B14].Locked = True
             'Clear details of last sale
            [A20:I41, I9, B9, B49, I49].ClearContents
            [B9].Select
     
            .Protect
            End With
            
      End Sub
    I don't know why it works with one sheet and not the other.

    All help gratefully recieved.


    I have attached the sheet in case its something on the sheet rather than the code,

    Thanks again
    Attached Files Attached Files

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