Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multiple Criteria Selection with VBA on an Autofilter

Posted on 2010-08-12
3
Medium Priority
?
586 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_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

719 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