AutoFilter

  • Thread starter Andrei Zakharov
  • Start date
A

Andrei Zakharov

Hi,

Is AutoFilter can be accessed programmatically? I don't mean
Application.AutoFilter method itself. I mean columns' filter settings.
Thank you.
 
J

John

Andrei Zakharov said:
Hi,

Is AutoFilter can be accessed programmatically? I don't mean
Application.AutoFilter method itself. I mean columns' filter settings.
Thank you.

Andrei,
As far as I know, it is only possible to activate or deactivate
autofilter using VBA. However, if you want to set filter values, it is
better to use the FilterEdit Method - it has much more flexibility.

John
Project MVP
 
A

Andrei Zakharov

Hi John,

Thanks for advice. Unfortunately, FilterEdit method doesn't allow to specify
several conditions simultaneously, but just the only one.

Andrei.
 
J

John

Andrei Zakharov said:
Hi John,

Thanks for advice. Unfortunately, FilterEdit method doesn't allow to specify
several conditions simultaneously, but just the only one.

Andrei.

Andrei,
Not true! The FilterEdit Method is much more flexible then a custom
autofilter. FilterEdit will allow the user to develop any complex filter
that can be developed under Project/Filtered for.

John
Project MVP
 
J

Jan De Messemaeker

Hi,

Let me be positive and propose the way I handle this
I make 1 filter (manually ot through VBA) which is Flag1 equals True (or
Yes)
Then I can use normal VBA statements to calculate Flag1.
This is much, much easier to code than FilterEdit and obviously you can
combine as many conditions as you like.

Hope this helps,

--
Jan De Messemaeker
Microsoft Project Most Valuable Professional
+32 495 300 620
For availability check:
http://users.online.be/prom-ade/Calendar.pdf
 
A

Andrei Zakharov

Oops, silly me :( Though the VBA doc isn't clear enough of how to create
complex filters, I mean usage of Parenthesis and Operation parameters, but
using of macro recording and Project/Filtered for dialog can get an
understanding of the stuff.
Thanks to all.

Andrei.
 
J

John

Andrei Zakharov said:
Oops, silly me :( Though the VBA doc isn't clear enough of how to create
complex filters, I mean usage of Parenthesis and Operation parameters, but
using of macro recording and Project/Filtered for dialog can get an
understanding of the stuff.
Thanks to all.

Andrei.

Andrei,
Ok, I'm glad we got that cleared up. You are right in that the Object
Browser isn't very thorough in explaining how to develop complex
filters. Below is an example of a complex filter from one of my macros.
It even includes some logic as part of the filter development. And yes,
it took me quite a while to figure it all out, but one good way to get
things started is to manually record a macro while a complex filter is
built. Then look at the resulting code and adjust accordingly.

'Structure variable filter based on user option inputs
' first line in filter is a placeholder for the 'create' and
'overwriteexisting' options in the FilterEdit syntax
' and it will also filter out any blank lines (don't need a "If Not t
is Nothing" Then statement)
FilterEdit Name:="CobraX", taskfilter:=True, create:=True,
overwriteexisting:=True, _
FieldName:="summary", test:="equals", Value:="no",
ShowInMenu:=False, showsummarytasks:=False
FilterEdit Name:="CobraX", taskfilter:=True, operation:="and", _
parenthesis:=True, newfieldname:="start", test:="is greater than or
equal to", Value:=SDate
FilterEdit Name:="CobraX", taskfilter:=True, _
operation:="or", newfieldname:="finish", test:="is greater than or
equal to", Value:=SDate
If OLFlag = True Then FilterEdit Name:="CobraX", taskfilter:=True,
operation:="and", _
parenthesis:=True, newfieldname:="outline level", test:="is less
than or equal to", _
Value:=frmCobra.TxBoxOutlineLvl.Value
If WBSFlag = True Then FilterEdit Name:="CobraX", taskfilter:=True,
operation:="and", _
parenthesis:=True, newfieldname:="Flag20", test:="equals",
Value:="yes"
FilterApply Name:="CobraX"

John
Project MVP
 

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

Similar Threads


Top