+ Reply to Thread
Results 1 to 3 of 3

Protect Cell from User Edit Based on Cell Interior Color

  1. #1
    Registered User
    Join Date
    01-10-2012
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    62

    Protect Cell from User Edit Based on Cell Interior Color

    Hi all,

    I am in need of a code that allows me to protect cells based on the interior cell color. I have looked around and found a few things but I can't seem to get it to work. I think the main issue is that a few of the cells in the worksheets are merged.

    What I need the code to do;
    Protect each cell from user edit if the cell interior color is ColorIndex 15. I need it to do this for a worksheet array that consists of sheet names from 'Mach-1', 'Mach-2', 'Mach-3', all the way up to 'Mach-16'. Like I mentioned before, some of the cells are merged.

    Is there a way to do this or am I out of luck?


    Thank You!

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Protect Cell from User Edit Based on Cell Interior Color

    merged cells can't be locked on their own, but they also have a mergearea property. I believe you can lock a cell's mergearea even if it is not merged so I think this will work, but is untested:

    Please Login or Register  to view this content.
    EDIT: As you probably know the sheet needs to be protected before the locked cell actually gets protected from change. If you want the code to lock the sheet also then you need to add a line between "Next myCell" and "Next sht_ctr", something like ws.Protect Password:="yourpassword"
    Last edited by Arkadi; 06-24-2015 at 04:17 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    01-10-2012
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2010
    Posts
    62

    Re: Protect Cell from User Edit Based on Cell Interior Color

    This works great. Thanks for your work!

+ 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. Move data based on cell color on each edit.
    By vitt4300 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-26-2013, 08:07 AM
  2. Find a duplicate and then use the duplicates interior.color to change cell color.
    By bopsgtir in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2012, 03:54 PM
  3. "If" and Syntax to change font and fill (interior) color based on cell value
    By jdfjab in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2012, 10:29 AM
  4. Cell background color (interior color) setting not working
    By Martin E. in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-21-2006, 02:10 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