Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and Autofilters

I want to know what the autofilter was last set to.
Below is a snipet of code.
For simplicity sake, lets just say I want to know what "Criteria1" was
last set on. Range("E118") is the autofilter.

Dim Count as String
Selection.AutoFilter Field:=5, Criteria1:="T&D Toolmakers"
Count = Range("E118").Value
MsgBox (Count)

It's not working, Help!


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default VBA and Autofilters

Frank,

This code dumps all the active filter criteria for Sheet1:

Sub testit()
Dim flt As Filter

For Each flt In Sheet1.AutoFilter.Filters
If flt.On Then
If flt.Operator = 0 Then
Debug.Print flt.Criteria1
Else
Debug.Print flt.Criteria1 & flt.Criteria2
End If
End If
Next
End Sub

Rob


"Frank Haverkamp " wrote in
message ...
I want to know what the autofilter was last set to.
Below is a snipet of code.
For simplicity sake, lets just say I want to know what "Criteria1" was
last set on. Range("E118") is the autofilter.

Dim Count as String
Selection.AutoFilter Field:=5, Criteria1:="T&D Toolmakers"
Count = Range("E118").Value
MsgBox (Count)

It's not working, Help!


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default VBA and Autofilters

If you want just one particular filter criteria do this:

Set w = Worksheets("Sheet1")
If w.AutoFilterMode Then
Criteriais = w.AutoFilter.Filters.Item(2).Criteria1
End If

Item(2) would be the 2nd filter from the left, Item(3) the 3rd and so on...

Mike
"Frank Haverkamp " wrote in
message ...
I want to know what the autofilter was last set to.
Below is a snipet of code.
For simplicity sake, lets just say I want to know what "Criteria1" was
last set on. Range("E118") is the autofilter.

Dim Count as String
Selection.AutoFilter Field:=5, Criteria1:="T&D Toolmakers"
Count = Range("E118").Value
MsgBox (Count)

It's not working, Help!


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Autofilters Rick Excel Discussion (Misc queries) 1 August 23rd 07 10:02 PM
AutoFilters Joli Excel Worksheet Functions 1 March 21st 06 09:14 PM
How to set up AutoFilters? MS Suzanne Excel Worksheet Functions 1 June 30th 05 03:53 AM
autofilters Diego Villaseñor Fernández Excel Worksheet Functions 0 January 13th 05 11:27 PM
Userforms and autofilters - Autofilters don't seen to work with userform No Name Excel Programming 3 August 28th 03 05:42 PM


All times are GMT +1. The time now is 07:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"