Solved

Multiple Criteria Selection with VBA on an Autofilter

Posted on 2010-08-12
3
584 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 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

729 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