+ Reply to Thread
Results 1 to 5 of 5

Having a cell display certain text or formatting when the worksheet is protected or unprotected

  1. #1
    jonco
    Guest

    Having a cell display certain text or formatting when the worksheet is protected or unprotected

    Is there an easy way to have a cell display certain text or formatting when
    the sheet is protected or unprotected? I'd like to have several cells,
    A32:D32 be colored red (for instance) when the worksheet is unprotected.

    You guys have been a GREAT help to me during this project. Thanks!!!!!

    Jon



  2. #2
    Jim Cone
    Guest

    Re: Having a cell display certain text or formatting when the worksheet is protected or unprotected

    This handles the entire used range on the active sheet.
    Change the range to suit...
    '------------------------------
    Sub ColorWhatsLocked()
    Dim rngCell As Excel.Range
    Application.ScreenUpdating = False
    ActiveSheet.UsedRange.Interior.ColorIndex = xlColorIndexNone
    For Each rngCell In ActiveSheet.UsedRange.Cells
    If rngCell.Locked Then rngCell.Interior.ColorIndex = 3
    Next 'rngCell
    Application.ScreenUpdating = True
    End Sub

    Sub RemoveColor()
    ActiveSheet.UsedRange.Interior.ColorIndex = xlColorIndexNone
    End Sub
    -------------
    Jim Cone
    San Francisco, USA
    http://www.realezsites.com/bus/primitivesoftware



    "jonco" <jonco48@sbcglobal.net>
    wrote in message
    Is there an easy way to have a cell display certain text or formatting when
    the sheet is protected or unprotected? I'd like to have several cells,
    A32:D32 be colored red (for instance) when the worksheet is unprotected.
    You guys have been a GREAT help to me during this project. Thanks!!!!!
    Jon



  3. #3
    Stefi
    Guest

    RE: Having a cell display certain text or formatting when the workshee

    This is a semi-automatic solution:
    Install this UDF:
    Function isprotected()
    Application.Volatile
    isprotected = ActiveSheet.ProtectContents
    End Function

    Apply = isprotected() as formula in Conditional formatting!

    It comes to force automaticly when opening the workbook, but unfortunately
    you have to press F9 (recalculate) to see the effect when changing Protect
    Status!

    Regards,
    Stefi


    „jonco” ezt Ã*rta:

    > Is there an easy way to have a cell display certain text or formatting when
    > the sheet is protected or unprotected? I'd like to have several cells,
    > A32:D32 be colored red (for instance) when the worksheet is unprotected.
    >
    > You guys have been a GREAT help to me during this project. Thanks!!!!!
    >
    > Jon
    >
    >
    >


  4. #4
    Ken Johnson
    Guest

    Re: Having a cell display certain text or formatting when the worksheet is protected or unprotected

    Hi jonco,

    Protecting the worksheet is not an event that can trigger any code,
    however, you could try the following code in either a
    Worksheet_SelectionChange Procedure or a Worksheet_Calculate
    Procedure...

    On Error GoTo PROTECTED
    Range("A32:D32").Interior.ColorIndex = xlNone
    Exit Sub
    PROTECTED:
    Me.Unprotect "password"
    Range("A32:D32").Interior.ColorIndex = 3
    Me.Protect "password"

    Edit "password" to your protection password or remove both if you don't
    use one.

    I believe that if any cell on the sheet has the RAND function it will
    force the sheet to calculate everytime you press Enter. This would be
    handy if the code is in the Worksheet_Calulate Procedure.

    Ken Johnson


  5. #5
    Ken Johnson
    Guest

    Re: Having a cell display certain text or formatting when the worksheet is protected or unprotected


    Hi Jonco,

    I take back what I said about Rand function forcing sheet calculation,
    so it's probably best to use the SelectionChange event.

    Ken Johnson


+ 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