Computing.Net > Forums > Office Software > Excel 2003 VBA code for filtering

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel 2003 VBA code for filtering

Reply to Message Icon

Name: ronnie_m80
Date: March 24, 2009 at 23:32:26 Pacific
OS: Windows XP
Subcategory: Microsoft Office
Comment:

Hello,

I need to perform an Autofilter function in Excel 2003 that allows me to filter a list using the contents of another cell as the criteria. For example, I need to filter the data in Column I against the value in cell E6. Now I know the basic code to filter against values equal to the contents of E6, which is:

Range("I11").Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
Selection.AutoFilter Field:=9, Criteria1:=Range("E6"), Operator:=xlAnd

However, how do I filter against values less than or equal to E6? I've tried playing around with this code but it only lets me set the criteria as less than or equal to a numeric value, i.e.

Range("I11").Select
Selection.AutoFilter
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
Selection.AutoFilter Field:=9, Criteria1:="<=7", Operator:=xlAnd

How can I write a code so that the list in Column I is filtered against values that are less than or equal to the contents of cell E6?



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: March 25, 2009 at 20:30:04 Pacific
Reply:

Range("I11").AutoFilter Field:=1, Criteria1:="<=" & Range("E6")


0

Response Number 2
Name: ronnie_m80
Date: March 25, 2009 at 23:54:02 Pacific
Reply:

Thanks DerbyDad03, that was exactly what I needed. Cheers!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Excel 2003 VBA code for filtering

Excel 2007 data bars for Excel 2003 www.computing.net/answers/office/excel-2007-data-bars-for-excel-2003/9304.html

Running excel VBA Code from a pre 2003 Macro www.computing.net/answers/office/running-excel-vba-code-from-a-pre-2003-macro/9591.html

Importing xml to excel 2003 www.computing.net/answers/office/importing-xml-to-excel-2003/6398.html