Solved

VBA Filter

Posted on 2013-01-24
3
262 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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…
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…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now