Using AutoFilter from VBA

I

Isis

I want to show data rows based on 2 conditions using OR not AND.

I want to show a row if it has a value in Field 14

OR

If it has no value in Field 12 AND a value in Field 16

I have some code that filters on one Field but I am having trouble making the
OR working.

Any way to do that ? Any help appreciated.

Thanks
 
C

Claus Busch

Hi,

Am 24 Jun 2014 13:33:58 GMT schrieb Isis:
I want to show data rows based on 2 conditions using OR not AND.

I want to show a row if it has a value in Field 14

OR

If it has no value in Field 12 AND a value in Field 16

try:

Sub HideRows()
Dim LRow As Long
Dim rngC As Range

With ActiveSheet
LRow = .Cells(Rows.Count, 1).End(xlUp).Row
For Each rngC In .Range("P2:p" & LRow)
If Len(rngC) = 0 And Len(rngC.Offset(, -4)) > 0 _
Or Len(rngC.Offset(, -2)) = 0 Then
.Rows(rngC.Row).Hidden = True
End If
Next
End With
End Sub


Regards
Claus B.
 

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