+ Reply to Thread
Results 1 to 2 of 2

Worksheet Password Protection Fails

  1. #1
    Registered User
    Join Date
    01-21-2009
    Location
    Nanning, China
    MS-Off Ver
    Excel 2003
    Posts
    12

    Worksheet Password Protection Fails

    Hello, My worksheet password protection fails after I enter data into the unprotected cells. Might it have something to do with how my VBA code is structured? I have attached my code for viewing. Thanks Everyone


    Private Sub Worksheet_Change(ByVal Target As Range)

    Sheets("Working Copy").Unprotect Password:="christmas"

    If Intersect(Target, Union(Range("E3:E20"), Range("I3:I20"), Range("M3:M20"), Range("Q3:Q20"), Range("U3:U20"), Range("Y3:Y20"))) Is Nothing Then Exit Sub
    ChangedRow = Target.Row
    ChangedCol = Target.Column

    Select Case Target.Value
    Case 1: TextColor = 4
    Case 2: TextColor = 13
    Case 3: TextColor = 9
    Case 4: TextColor = 5
    Case 5: TextColor = 7
    Case 6: TextColor = 41
    Case 7: TextColor = 46
    Case 8: TextColor = 12
    Case Else: TextColor = 0
    End Select

    Target.Offset(, 2).Font.ColorIndex = TextColor
    CorrespondingCol = (ChangedCol - 1) / 4 + 3
    Worksheets("Finished Schedule").Cells(ChangedRow + 1, CorrespondingCol).Font.ColorIndex = TextColor

    Sheets("Working Copy").Protect Password:="christmas"
    End Sub

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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