+ Reply to Thread
Results 1 to 4 of 4

Protecting cells by coluor

  1. #1
    Registered User
    Join Date
    01-12-2005
    Posts
    13

    Protecting cells by coluor

    I have used 3 colours in my spreadsheet 1 for headings /titles, 1 for data entry and 1 for calculated fields. How can I protect all cells with a specific colour to prevent users from changing contents / formula

  2. #2
    Rowan Drummond
    Guest

    Re: Protecting cells by coluor

    Protects all cells which are coloured Light Yellow (colour index 36):

    Sub PrtcColor()
    Dim cell As Range
    With ActiveSheet
    .Unprotect
    For Each cell In .UsedRange
    If cell.Interior.ColorIndex = 36 Then
    cell.Locked = True
    Else
    cell.Locked = False
    End If
    Next cell
    .Protect
    End With
    End Sub

    Hope this helps
    Rowan

    st120869 wrote:
    > I have used 3 colours in my spreadsheet 1 for headings /titles, 1 for
    > data entry and 1 for calculated fields. How can I protect all cells
    > with a specific colour to prevent users from changing contents /
    > formula
    >
    >


  3. #3
    Registered User
    Join Date
    01-12-2005
    Posts
    13
    Great, thanks this works. As an aside it will not work if any cells are merged - took a while to work this one out as I kept on getting an error message.

  4. #4
    Rowan Drummond
    Guest

    Re: Protecting cells by coluor

    You're welcome. You will find a lot of things don't work with merged
    cells. As a result I never use them.

    Regards
    Rowan

    st120869 wrote:
    > Great, thanks this works. As an aside it will not work if any cells are
    > merged - took a while to work this one out as I kept on getting an
    > error message.
    >
    >


+ 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