PDA

View Full Version : SPPID Automation - Loop through filter criteria?



dave
01-20-2011, 08:23 AM
I have a routine (pretty much strait from the book) that loops through the filters



For Each objFilter In datasource.Filters 'objFiltersCollection
If objFilter.Name = myFilter Then

If Not objFilter.Criteria Is Nothing Then

If objFilter.Criteria.Count >= 1 Then

i = 1

MyIndex = objFilter.Criteria.Item(1).ValueAttribute
FindCodeList datasource, MyIndex, myIndexOut

ThisWorkbook.Worksheets("Sheet1").Activate
Cells(i, 1).Value = "Filter item type = " & objFilter.ItemType & Space(20 - Len(objFilter.ItemType)) _
& "Filter name = " & objFilter.Name & " " _
& objFilter.Criteria.Item(1).SourceAttributeName _
& objFilter.Criteria.Item(1).Operator _
& myIndexOut

i = i + 1
End If
End If
End If
Next


When I find the correct filter name here


For Each objFilter In datasource.Filters 'objFiltersCollection
If objFilter.Name = myFilter Then

If Not objFilter.Criteria Is Nothing Then

If objFilter.Criteria.Count >= 1 Then 'I need to loop through the filter criteria now


Instead of just saying "if the count is > 1 then", I need to loop through the filter criteria. What does that look like?

Thanks!

smartman
01-20-2011, 08:31 PM
@Dave I guess the code "if the count is > 1 then" ensures that there is at least one criterion. isnt it? if this condition is not true that means filter is not having any criterion.

dave
01-20-2011, 09:21 PM
I should have replied to this sooner. I was able to loop through the criteria by adding something like the following:



For n = 1 to objFilter.Criteria.Count
debug.print objFilter.Name '(etc)
next


cheers dude