Solved

Multiple Criteria Selection with VBA on an Autofilter

Posted on 2010-08-12
3
578 Views
Last Modified: 2012-06-27
I'm sure for anyone with some VBA experience this will be easy as, but for me who has no clue I don't know where to start.

I have a macro pulling data from one sheet with an autofilter on and pasting the data on another:

Range("V3").Select
    ActiveSheet.Range("$A$1:$AG$999").AutoFilter Field:=28, Criteria1:= _
        "Service"
    Range("A1:AG999").Select
    Range("V3").Activate
    Selection.Copy
    Sheets("Email Data").Select
    ActiveSheet.Paste


All i want to do is simply enter another option e.g.

    ActiveSheet.Range("$A$1:$AG$999").AutoFilter Field:=28, Criteria1:= _
        "Service" or "MOT" or "Service And MOT"

but as you will probably notice I have no idea of how to do this. How exactly should i type this into VBA please so it doesn't just pull the "service" data but also the "MOT" and the "Service and MOT"?
0
Comment
Question by:ali_
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 125 total points
ID: 33422212
Are there other values containing Service or MOT other than those three above? You can't have three criteria with AutoFilter so would need a workaround or another method if anwer to previous question was yes. Otherwise, could try

ActiveSheet.Range("$A$1:$AG$999").AutoFilter Field:=28, Criteria1:="=*MOT*", _
        Operator:=xlOr, Criteria2:="=*Service*"
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 33422219
TO clarify, above will return any entry containing MOT or Service.
0
 

Author Closing Comment

by:ali_
ID: 33422656
Spot on. Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now