ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiple Filter in VBA (https://www.excelbanter.com/excel-programming/283881-multiple-filter-vba.html)

Kevin McLean

Multiple Filter in VBA
 
I have an excel sheet with 7 columns of data and I would
like to write VBA to filter the 3rd and 4th columns for
the value "0.00". If a record has zero in both the 3rd
and 4th columns I want it displayed. Otherwise, I want it
to be filtered out.

I used the record funcation and received this output:

Selection.AutoFilter Field:=3, Criteria1:="=0.00",
Operator:=xlAnd
Selection.AutoFilter Field:=4, Criteria1:="=0.00",
Operator:=xlAnd

Please help.

Thank you,
Kevin

Trevor Shuttleworth

Multiple Filter in VBA
 
Kevin

You don't actually say what you want help with. What doesn't happen that
should ? What does happen that shouldn't ?

When I recorded the macro I got this code:

Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="0"
Selection.AutoFilter Field:=4, Criteria1:="0"

This can be tidied up a little:

With Selection
.AutoFilter
.AutoFilter Field:=3, Criteria1:="0"
.AutoFilter Field:=4, Criteria1:="0"
End With

Bear in mind that numeric 0.00 will be stored as 0. Are you looking for
text "0.00" ?

Regards

Trevor


"Kevin McLean" wrote in message
...
I have an excel sheet with 7 columns of data and I would
like to write VBA to filter the 3rd and 4th columns for
the value "0.00". If a record has zero in both the 3rd
and 4th columns I want it displayed. Otherwise, I want it
to be filtered out.

I used the record funcation and received this output:

Selection.AutoFilter Field:=3, Criteria1:="=0.00",
Operator:=xlAnd
Selection.AutoFilter Field:=4, Criteria1:="=0.00",
Operator:=xlAnd

Please help.

Thank you,
Kevin





All times are GMT +1. The time now is 08:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com