Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA Filter

Posted on 2013-01-24
3
Medium Priority
?
313 Views
Last Modified: 2013-01-24
Hi,

Im looking for code to filter for "XYZ in column A

If there is no "XYZ" then i need the code to just ignore and move on, not to bomb out!

Has anyone such code?

Thanks!
0
Comment
Question by:Seamus2626
[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 26

Accepted Solution

by:
redmondb earned 2000 total points
ID: 38813935
Hi, Seamus2626,

I'm not sure I understand your requirements properly as filtering on a non-existent value doesn't cause an error...
Option Explicit

Sub Column_A()

If Not ActiveSheet.AutoFilterMode Then ActiveSheet.UsedRange.AutoFilter
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
ActiveSheet.Range("A:A").AutoFilter Field:=1, Criteria1:="=xyz", Operator:=xlAnd

End Sub

Open in new window

Regardsm
Brian.
0
 

Author Closing Comment

by:Seamus2626
ID: 38813947
All good Brian!
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38813954
Short and sweet - thanks, Seamus2626!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
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…

610 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