If statment with two conditions

  • Thread starter brownti via OfficeKB.com
  • Start date
B

brownti via OfficeKB.com

I have an IF statement with two condtions as noted below. I want it to work
so that if column G has a y in it, it will be hidden, and also if column G
has an N in it and column O has a 0 then it will be hidden. The second part
doesnt work. Any thoughts?

Sub Hide_new()
Dim cell As Range
Dim rngisect As Range

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Set rngisect = Application.Intersect(ActiveSheet.UsedRange, Range("G19:
G4061"))
For Each cell In rngisect
If cell.Value = "Y" Then
cell.EntireRow.Hidden = True
ElseIf cell.Value = "N" And cell.Offset(8).Value = "0" Then
cell.EntireRow.Hidden = True
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top