+ Reply to Thread
Results 1 to 3 of 3

protection of a workbook + unprotecting specific cells + calculation auto

  1. #1
    Registered User
    Join Date
    05-22-2008
    Posts
    5

    protection of a workbook + unprotecting specific cells + calculation auto

    hello,

    I am new here (and pretty new to vba too!). I would have a couple of questions that I hope you can help me with.

    in terms of performance is it better to turn off the automatic calculation in workbook_open and turn it on again when launching a macro?

    I have just learned how to protect a workbook and its worksheets.
    now users can no longer move/add/delete worksheets and change data within the worksheets.

    now I'd like to allow users to change data in specific cells.
    so: is it possible to unprotect cells in the workbook that are colored in grey? (and prevent users to change the color of the cell)

    thank you
    +++
    alex

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481
    Quote Originally Posted by choubix
    hello,

    I am new here (and pretty new to vba too!). I would have a couple of questions that I hope you can help me with.

    in terms of performance is it better to turn off the automatic calculation in workbook_open and turn it on again when launching a macro?

    I have just learned how to protect a workbook and its worksheets.
    now users can no longer move/add/delete worksheets and change data within the worksheets.

    now I'd like to allow users to change data in specific cells.
    so: is it possible to unprotect cells in the workbook that are colored in grey? (and prevent users to change the color of the cell)
    thank you
    +++
    alex
    Hi Alex,
    To enable users to edit specific cells, those cells have to be unlocked,
    With the sheet unprotected, select the cells that you want to allow editing,
    right click on the mouse one of the highlited cells and select format cells, select the protection tab and then uncheck locked,
    Protect the sheet and make sure you allow "select unlocked cells",(depending on the version of excel you are using).

    Under normal circumstances, setting calculate to manual is not necessary...

  3. #3
    Registered User
    Join Date
    05-22-2008
    Posts
    5
    hi dave, thanks for your reply!

    I have managed to find a code in vba to allow users to use cells of a certain color:

    PHP Code: 
    Sub UnprotectYellowCells()
         
    'Macro purpose:  To unlock all green cells
         '
    NOTE:  All worksheets in the workbook must be
         
    '       unprotected before this procedure is run
         
        Dim cl As Range, ws As Worksheet, lColor As Long
         
         '
    Set the cell color that you want to protect
        lColor 
    36 'yellow
         
         '
    It may be a good idea to test all sheets to see if any are protected
         
    'here.  One method to do this would be to test the function found here
         '
    http://www.vbaexpress.com/kb/getarticle.php?kb_id=551
         
         
    'Cycle through each worksheet in the workbook
        For Each ws In ActiveWorkbook.Worksheets
            For Each cl In ws.UsedRange
                 '
    Change colored cell to unlocked, and
                 
    'all other cells to locked
                If cl.Interior.ColorIndex = lColor Then
                    cl.Locked = False
                Else
                    cl.Locked = True
                End If
            Next cl
        Next ws
         
    End Sub 
    works like a charm.

+ 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