Hi,
I have a macro which hides some rows depending on which values we have in cells B2 and B3.
This macro works fine and hides all rows which DO NOT have "No" or "Not OK" in Cells(x,1) if in B2 we have "Yes" and in B3 we have "OK".
If I change code so that we have
I would expect macro to hide all rows which HAVE "No" or "Not OK" in Cells(x,1) if in B2 we have "Yes" and in B3 we have "OK".
But macro does not work this time.
If we put condition = instead of <> the macro stops working.
Does anyone know how I need to change code so that it works with equal sign as well (i.e. =)?
Thanks,
N.
I have a macro which hides some rows depending on which values we have in cells B2 and B3.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Range("B2").Value = "Yes" And Range("B3").Value = "OK" Then
For x = 20 To 5 Step -1
If Cells(x, 1) <> "No" And Cells(x, 1) <> "Not OK" Then
Rows(x).Hidden = True
Else
Rows(x).Hidden = False
End If
Next x
End If
End Sub
This macro works fine and hides all rows which DO NOT have "No" or "Not OK" in Cells(x,1) if in B2 we have "Yes" and in B3 we have "OK".
If I change code so that we have
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
'Range F10 = London client owner acting as:
If Range("B2").Value = "Yes" And Range("B3").Value = "OK" Then
For x = 20 To 5 Step -1
If Cells(x, 1) = "No" And Cells(x, 1) = "Not OK" Then
Rows(x).Hidden = True
Else
Rows(x).Hidden = False
End If
Next x
End If
End Sub
I would expect macro to hide all rows which HAVE "No" or "Not OK" in Cells(x,1) if in B2 we have "Yes" and in B3 we have "OK".
But macro does not work this time.
If we put condition = instead of <> the macro stops working.
Does anyone know how I need to change code so that it works with equal sign as well (i.e. =)?
Thanks,
N.