+ Reply to Thread
Results 1 to 7 of 7

locking and unlocking cells in a macro (multiple pages)

  1. #1
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    locking and unlocking cells in a macro (multiple pages)

    Can anyone tell me how in a macro to unprotect all sheets unlock cells in columns A - D and then lock the same when the macro is re run......protecting the sheets again is not necessary as when sheets are changed the locked cells are protected.

    Hoping you can help,

    Simon

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Working on this!

    Hi all, i am still trying to unprotect sheets and unlock cells in columns a-d as an array using a command button, this is the code i have so far......without the unprotect command it works fine, but if you protect a sheet it will not unprotect it any ideas?

    Simon.


    Sub cellunlock()

    With Workbook
    Worksheets(Sheets).Unprotect
    Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
    Sheets("Sheet1").Activate
    Columns("A:D").Select
    Selection.Locked = False
    Selection.FormulaHidden = False


    End With

    End Sub

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,641
    Hi Simon,

    try to protect all the sheets

    Protect userinterfaceonly:=Ture

    that enables only macro to run even when sheet is protected.

    hope this helps

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Hi jindon,

    Thanks for that, i'm not having a problem protecting individual sheets.....i need to be able to select all the pages as a group (excluding the sheet named "Hidden") unprotect all the sheets and then unlock all the cells in columns A - D when i click on the command button, i will then adapt the code so that when the button is clicked again it locks and protects the sheets (protection is without passwords on purpose).

    Simon

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,641
    Simon
    try this
    Please Login or Register  to view this content.
    rgds,
    jindon

  6. #6
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Hi Jindon,
    well i used your code and when i run it in place it gives me the error below....any ideas?, shall i mail you the workbook? its around 3.5Mb

    Run-time error 1004 Unable to set locked property of range class

    thanks

    Simon

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,641
    Hi

    I guess some or all sheets are protected.

    Please Login or Register  to view this content.
    rgds,
    jindon

+ 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