?
Solved

VBA Filter

Posted on 2013-01-24
3
Medium Priority
?
308 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

777 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