ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filtering columns within VB (https://www.excelbanter.com/excel-programming/367789-filtering-columns-within-vbulletin.html)

Darin Kramer

Filtering columns within VB
 


HI guys,

an extract of my vb is below:

With Sheets("Master").Range("A2:fs168")
.AutoFilter Field:=11, Criteria1:="Y"
.AutoFilter Field:=39, Criteria1:="N"
.AutoFilter Field:=40, Criteria1:="N"
.SpecialCells(xlCellTypeVisible).Copy _
Sheets("Results").Range("a2")

Basically I need to obtain all instances of Y in field 11, and ANY
Instance of N in field 39 and 40 (and other fields)
So for eg if a record has the following properties :

11 - Y
39 - Y
40 - n

The above filter will not work as within field 39 there is a Y. I need
the filter to be OR, ie if a N within 39 or 40 then show it.

I cant use advanced filters as I need this to be run through VB and to
have this copied to another sheet (plus couldent get advanced filters to
produce the result...?)

Too complicated...???

Thanks

D

*** Sent via Developersdex http://www.developersdex.com ***

Don Guillett

Filtering columns within VB
 
have you tried having the macro copy the advanced filter to a named range.

--
Don Guillett
SalesAid Software

"Darin Kramer" wrote in message
...


HI guys,

an extract of my vb is below:

With Sheets("Master").Range("A2:fs168")
.AutoFilter Field:=11, Criteria1:="Y"
.AutoFilter Field:=39, Criteria1:="N"
.AutoFilter Field:=40, Criteria1:="N"
.SpecialCells(xlCellTypeVisible).Copy _
Sheets("Results").Range("a2")

Basically I need to obtain all instances of Y in field 11, and ANY
Instance of N in field 39 and 40 (and other fields)
So for eg if a record has the following properties :

11 - Y
39 - Y
40 - n

The above filter will not work as within field 39 there is a Y. I need
the filter to be OR, ie if a N within 39 or 40 then show it.

I cant use advanced filters as I need this to be run through VB and to
have this copied to another sheet (plus couldent get advanced filters to
produce the result...?)

Too complicated...???

Thanks

D

*** Sent via Developersdex
http://www.developersdex.com ***




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

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