#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default AutoFilter

I got some good responses regarding the autofilter problem from Dave
Peterson and Debra Dalgleish.
================
to check for multiple criteria in the same column, you could use a
formula like:

=OR(D2="A",D2="B",D2="C")
Just to save typing:
=OR(D2={"A","B","C"})

Or list the multiple criteria on the worksheet, then check if the value
in the current row is in the list, e.g.:

=COUNTIF($K$2:$K$4,D2)0
================
However, I don't know how to apply these. The formula I was using is:
Selection.Autofilter Field:=10, Criteria1:="A"

When I try to apply the "OR" example, I get an error.

I have a user form that has 5 checkboxes to select the filter for the
particular field.
How do I build the filter phrase in VBA?

GMet


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default AutoFilter

Additional info:
I got a suggestion from Norman Jones to use Advanced Filter

The help says:
Range("Database").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Range("Criteria")I don't understand
CriteriaRange:=Range("Criteria")

I want to filter range(J10:J1000) if the range = "A" or "C" or "L" or "B" or
"T" based on what the user selects in my userform.

Seems like a simple thing but I don't know how to do it.

GMet


"GMet" wrote in message
...
I got some good responses regarding the autofilter problem from Dave
Peterson and Debra Dalgleish.
================
to check for multiple criteria in the same column, you could use a
formula like:

=OR(D2="A",D2="B",D2="C")
Just to save typing:
=OR(D2={"A","B","C"})

Or list the multiple criteria on the worksheet, then check if the value
in the current row is in the list, e.g.:

=COUNTIF($K$2:$K$4,D2)0
================
However, I don't know how to apply these. The formula I was using is:
Selection.Autofilter Field:=10, Criteria1:="A"

When I try to apply the "OR" example, I get an error.

I have a user form that has 5 checkboxes to select the filter for the
particular field.
How do I build the filter phrase in VBA?

GMet




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default AutoFilter

The mean to go to the next available column and enter the formula, then drag
fill it down the column.

for code it would be

Sub Tester2()
Dim rng As Range
Range("A4").CurrentRegion.Select
Set rng = Selection.Offset(0, Selection.Columns.Count).Resize(, 1)
rng.Formula = "=OR(" & "D" & rng(1).Row & "=""A"",D" & _
rng(1).Row & "=""B"",D" & _
rng(1).Row & "=""C"")"
rng(1).Value = "Header1"
Union(Selection, rng).Select
Selection.AutoFilter Field:=Selection.Columns.Count, Criteria1:=True
End Sub

--
Regards,
Tom Ogilvy

"GMet" wrote in message
...
I got some good responses regarding the autofilter problem from Dave
Peterson and Debra Dalgleish.
================
to check for multiple criteria in the same column, you could use a
formula like:

=OR(D2="A",D2="B",D2="C")
Just to save typing:
=OR(D2={"A","B","C"})

Or list the multiple criteria on the worksheet, then check if the value
in the current row is in the list, e.g.:

=COUNTIF($K$2:$K$4,D2)0
================
However, I don't know how to apply these. The formula I was using is:
Selection.Autofilter Field:=10, Criteria1:="A"

When I try to apply the "OR" example, I get an error.

I have a user form that has 5 checkboxes to select the filter for the
particular field.
How do I build the filter phrase in VBA?

GMet




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2007 autofilter change to 2003 autofilter functionality? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 10:05 PM
2007 excel autofilter back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 3 April 19th 10 08:11 PM
2007 excel autofilter change back to 2003 autofilter? jonnybrovo815 Excel Discussion (Misc queries) 1 April 19th 10 05:53 PM
2007 Autofilter worse than 2003 Autofilter jsky Excel Discussion (Misc queries) 9 October 31st 07 12:14 AM
How to Sort within AutoFilter with Protection on (and AutoFilter . giblon Excel Discussion (Misc queries) 1 February 16th 06 12:23 PM


All times are GMT +1. The time now is 12:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"