Hi
I am having a similar problem to Bob@sun.
I am new at VBA's and can't figure out how to incorporate the 'Userinterfaceonly" part into my code
Basically:
- I want If column 3 (i.e. c) is zero, then I want to hide rows 44-57 , 66-69, and 91 - 104
- This works until i protect the worksheet
- I have tried to incorporate 'ActiveSheet.Unprotect Passsword: ='Secret' and ActiveSheet.Unprotect Password:="Secret" but can't subsequently unprotect my worksheet
How can I run VBA in a protected worksheet without it subsequently being all protected?
this is my code:
Sub HURows()
ActiveSheet.Unprotect Password:="Secret"
BeginRow = 44
EndRow = 57
ChkCol = 3
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 0 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
BeginRow = 66
EndRow = 79
ChkCol = 3
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 0 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
BeginRow = 91
EndRow = 104
ChkCol = 3
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 0 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
ActiveSheet.Unprotect Password:="Secret"
End Sub
Any help with telling me how my code should be is much appreciated!!
thanks
Bookmarks