ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I control Auto Filter in VBA (https://www.excelbanter.com/excel-programming/364607-how-do-i-control-auto-filter-vba.html)

Mallycat[_2_]

How do I control Auto Filter in VBA
 

I want to be able to control an autofilter from VBA.

eg say I have a table with the following headings

Animal Name Age

In the animal column, the data is either Cat or Dog.

How can I create a Macro to select Cat or Dog in the Auto Filter?

Matt


--
Mallycat
------------------------------------------------------------------------
Mallycat's Profile: http://www.excelforum.com/member.php...o&userid=35514
View this thread: http://www.excelforum.com/showthread...hreadid=552982


Tom Ogilvy

How do I control Auto Filter in VBA
 
Selection.Autofilter Filter:=1, Criteria1:="Cat"

--
Regards,
Tom Ogilvy

"Mallycat" wrote in
message ...

I want to be able to control an autofilter from VBA.

eg say I have a table with the following headings

Animal Name Age

In the animal column, the data is either Cat or Dog.

How can I create a Macro to select Cat or Dog in the Auto Filter?

Matt


--
Mallycat
------------------------------------------------------------------------
Mallycat's Profile:

http://www.excelforum.com/member.php...o&userid=35514
View this thread: http://www.excelforum.com/showthread...hreadid=552982




Mallycat[_4_]

How do I control Auto Filter in VBA
 

Tom Ogilvy Wrote:
Selection.Autofilter Filter:=1, Criteria1:="Cat"


Thanks. So easy when you know how. I haven't been able to get this to
work previously.

Matt


--
Mallycat
------------------------------------------------------------------------
Mallycat's Profile: http://www.excelforum.com/member.php...o&userid=35514
View this thread: http://www.excelforum.com/showthread...hreadid=552982


Nigel

How do I control Auto Filter in VBA
 
try using the macro recorder it will create the code you need

--
Cheers
Nigel



"Mallycat" wrote in
message ...

Tom Ogilvy Wrote:
Selection.Autofilter Filter:=1, Criteria1:="Cat"


Thanks. So easy when you know how. I haven't been able to get this to
work previously.

Matt


--
Mallycat
------------------------------------------------------------------------
Mallycat's Profile:
http://www.excelforum.com/member.php...o&userid=35514
View this thread: http://www.excelforum.com/showthread...hreadid=552982





All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com