View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default remembering the same filtering criteria

Hi GS,

Unfortunately that was not what I wanted. I know that you can set the
criteria from a cell(A1). But what I want to store a filtered
criteria in one cell(A1) then I remove the filter.After that I run
another macro then I want to put back my filter with the same
criteria as in Range A1. Thanks for your help Baha


You can store the criteria in a variable during runtime, and access it
anytime...

In a standard module:
Public sFilterCriteria$ '//stores last used criteria


Sub Set_AutoFilter()
If sCriteria = "" Then sCriteria = Range("A1").Value
With ActiveSheet
If .AutoFilterMode Then .AutoFilterMode = False
With .Range("$A$2:$A$11")
.AutoFilter
.AutoFilter Field:=1, Criteria1:=sFilterCriteria
End With '.Range("$A$2:$A$11")
End With 'ActiveSheet
End Sub

Sub Reset_FilterCriteria()
sFilterCriteria = ""
End Sub

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion