Solved

VBA Filter

Posted on 2013-01-24
3
304 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 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…

695 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