Can i use IsEmpty and IF this way? What's wrong here?

C

changeable

Opps, i have another problem. I try to do the filtering by this way:


Code
-------------------
For i = 1 To 10
If Not (IsEmpty(arr.Cells(i, 2)) And IsEmpty(arr.Cells(i, 3))) Then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 2), Operator:=xlAnd, Criteria2:=arr(i, 3)

ElseIf Not (IsEmpty(arr.Cells(i, 4)) And IsEmpty(arr.Cells(i, 5))) Then
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 4), Operator:=xlAnd, Criteria2:=arr(i, 5)

End If
End If
Cells(38041 + j, 6 + i).Value = Range("F38039")
Next
-------------------


however, the results doesnt look to be what i am especting. And i thin
that it is because the criteria i selected in Field 5 doesnt reset eac
time a new "i" is used.
Can anyone tell me how to reset the Autofiltering after each "i" i
executed?

Thanks agai
 
T

Tom Ogilvy

if Activesheet.filterMode then
ActiveSheet.ShowAll
End If
For i = 1 To 10
If Not (IsEmpty(arr.Cells(i, 2)) And IsEmpty(arr.Cells(i, 3))) Then
Selection.AutoFilter Field:=5, Criteria1:=arr(i, 2), Operator:=xlAnd,
Criteria2:=arr(i, 3)

ElseIf Not (IsEmpty(arr.Cells(i, 4)) And IsEmpty(arr.Cells(i, 5))) Then
Selection.AutoFilter Field:=6, Criteria1:=arr(i, 4), Operator:=xlAnd,
Criteria2:=arr(i, 5)

End If
End If
Cells(38041 + j, 6 + i).Value = Range("F38039")
Next i
 

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