Results 1 to 7 of 7

Protecting and unprotecting a cell

Threaded View

  1. #1
    Registered User
    Join Date
    01-08-2010
    Location
    Montréal Québec
    MS-Off Ver
    Excel 2003
    Posts
    9

    Protecting and unprotecting a cell

    Hi,

    My little loop checks if the value in a cell equals a number. At first, it hides or unhides rows if it equals the number I am looking for(Works Perfect). It then checks another colums to see if it equals another number I am looking for, and it "should" protect or unprotect another cell in the same row(the part where I have problems with).

    Here is my code:
    Sub HURows()
        BeginRow = 1
        EndRow = 181
        ChkCol = 16
        ChkCol2 = 18
        Password = "TI9779"
    
        For RowCnt = BeginRow To EndRow
                If Cells(RowCnt, ChkCol).Value = 1 Then
                    Cells(RowCnt, ChkCol).EntireRow.Hidden = True
                Else
                    Cells(RowCnt, ChkCol).EntireRow.Hidden = False
                End If
                If Cells(RowCnt, ChkCol2).Value = 1 Then
                    Sheet2.Unprotect Password
                    Range("$G(RowCnt)").Locked = True
                    Sheet2.Protect Password, False, False, False, False, False, False, True
                                    
                    If Cells(RowCnt, ChkCol2).Value = 2 Then
                        Sheet2.Unprotect Password
                        Range("$G(RowCnt)").Locked = False
                        Sheet2.Protect Password, False, False, False, False, False, False, True
                    End If
                End If
    
        Next RowCnt
    End Sub
    Last edited by royUK; 01-08-2010 at 01:13 PM. Reason: add code tags

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