+ Reply to Thread
Results 1 to 4 of 4

Lock condition based on a background fill

  1. #1
    Registered User
    Join Date
    03-14-2006
    Posts
    3

    Lock condition based on a background fill

    Obviously an IF condition, but my knowledge ends here...

    All I need is a condition that lock all cells in a worksheet, that has a background fill. That condition should be activate when opening workbook

    Seems easy, no?

    Thanks, ppl!

  2. #2
    Tom Ogilvy
    Guest

    RE: Lock condition based on a background fill

    in the Thisworkbook module, use the workbook_open event
    http://www.cpearson.com/excel/events.htm

    Private Sub Workbook_Open
    with worksheets("sheet1")
    set rng = .UsedRange
    .Unprotect Password:="ABCD"
    for each cell in rng
    if cell.Interior.ColorIndex <> xlNone then
    cell.locked = True
    end if
    Next
    .Protect Password:="ABCD"
    End with
    End Sub

    --
    Regards,
    Tom Ogilvy


    "jobeer" wrote:

    >
    > Obviously an IF condition, but my knowledge ends here...
    >
    > All I need is a condition that lock all cells in a worksheet, that has
    > a background fill. That condition should be activate when opening
    > workbook
    >
    > Seems easy, no?
    >
    > Thanks, ppl!
    >
    >
    > --
    > jobeer
    > ------------------------------------------------------------------------
    > jobeer's Profile: http://www.excelforum.com/member.php...o&userid=32447
    > View this thread: http://www.excelforum.com/showthread...hreadid=523145
    >
    >


  3. #3
    Registered User
    Join Date
    03-14-2006
    Posts
    3

    thanks! just one more thing...

    These cell have values... is there a way to protect them too?

    ok, lets say: I have a table with the days of a month (obtained by formula).
    Some days are weekend or hollidays. These particular cells have a background fill.
    This worksheet is to set holliday periods for employees. So I don't want to select Christmas or other hollidays, got it?

    So these cells with numbers should be protected, but not for edition, because of the background fill change!

    Is this possible?

  4. #4
    Tom Ogilvy
    Guest

    Re: Lock condition based on a background fill

    No I don't got it. I gave you what you asked for. It is unclear how your
    additional information has changed that. The only addendum I would add, is
    if the sheet is static, you certainly don't need a macro to do this. Set it
    up manually and be done with it.

    --
    Regards,
    Tom Ogilvy

    "jobeer" wrote:

    >
    > These cell have values... is there a way to protect them too?
    >
    >
    > ok, lets say: I have a table with the days of a month (obtained by
    > formula).
    > Some days are weekend or hollidays. These particular cells have a
    > background fill.
    > This worksheet is to set holliday periods for employees. So I don't
    > want to select Christmas or other hollidays, got it?
    >
    > So these cells with numbers should be protected, but not for edition,
    > because of the background fill change!
    >
    > Is this possible?
    >
    >
    > --
    > jobeer
    > ------------------------------------------------------------------------
    > jobeer's Profile: http://www.excelforum.com/member.php...o&userid=32447
    > View this thread: http://www.excelforum.com/showthread...hreadid=523145
    >
    >


+ 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