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
Bookmarks