![]() |
xl2002 - AutoFilter from Criteria from Other Sheet...
I am trying to apply an AutoFilter to records on "Sheet 2" using criteria
chosen from 7 lists on "Sheet 1" The filtering works if each criteria contains a value, but if one is left blank no records are shown. I have tried adding the value "(all)" as a default into the lists on Sheet 1 but that doesn't work either. How can I skip 'blank' entries when filtering using code? (current code below) Thanks Trevor Sub FilterResult() myFilter = Array("ctDescription", "ctMarket", "ctPOB", "ctChannel", _ "ctCategory", "ctQuality", "ctCompetition") For i = 0 To 6 x = myFilter(i) Selection.AutoFilter Field:=i + 1, Criteria1:=Range(x), _ VisibleDropDown:=False Next i End Sub |
xl2002 - AutoFilter from Criteria from Other Sheet...
Sub FilterResult()
myFilter = Array("ctDescription", "ctMarket", "ctPOB", "ctChannel", _ "ctCategory", "ctQuality", "ctCompetition") For i = 0 To 6 x = myFilter(i) set rng = Range(x) if rng.Value < "" then Selection.AutoFilter Field:=i + 1, Criteria1:=Range(x), _ VisibleDropDown:=False else Selection.AutoFilter Field:=i + 1, _ VisibleDropDown:=False end if Next i End Sub -- Regards, Tom Ogilvy "Trevor Williams" wrote: I am trying to apply an AutoFilter to records on "Sheet 2" using criteria chosen from 7 lists on "Sheet 1" The filtering works if each criteria contains a value, but if one is left blank no records are shown. I have tried adding the value "(all)" as a default into the lists on Sheet 1 but that doesn't work either. How can I skip 'blank' entries when filtering using code? (current code below) Thanks Trevor Sub FilterResult() myFilter = Array("ctDescription", "ctMarket", "ctPOB", "ctChannel", _ "ctCategory", "ctQuality", "ctCompetition") For i = 0 To 6 x = myFilter(i) Selection.AutoFilter Field:=i + 1, Criteria1:=Range(x), _ VisibleDropDown:=False Next i End Sub |
xl2002 - AutoFilter from Criteria from Other Sheet...
Excellent, Thanks Tom
Trevor "Tom Ogilvy" wrote: Sub FilterResult() myFilter = Array("ctDescription", "ctMarket", "ctPOB", "ctChannel", _ "ctCategory", "ctQuality", "ctCompetition") For i = 0 To 6 x = myFilter(i) set rng = Range(x) if rng.Value < "" then Selection.AutoFilter Field:=i + 1, Criteria1:=Range(x), _ VisibleDropDown:=False else Selection.AutoFilter Field:=i + 1, _ VisibleDropDown:=False end if Next i End Sub -- Regards, Tom Ogilvy "Trevor Williams" wrote: I am trying to apply an AutoFilter to records on "Sheet 2" using criteria chosen from 7 lists on "Sheet 1" The filtering works if each criteria contains a value, but if one is left blank no records are shown. I have tried adding the value "(all)" as a default into the lists on Sheet 1 but that doesn't work either. How can I skip 'blank' entries when filtering using code? (current code below) Thanks Trevor Sub FilterResult() myFilter = Array("ctDescription", "ctMarket", "ctPOB", "ctChannel", _ "ctCategory", "ctQuality", "ctCompetition") For i = 0 To 6 x = myFilter(i) Selection.AutoFilter Field:=i + 1, Criteria1:=Range(x), _ VisibleDropDown:=False Next i End Sub |
All times are GMT +1. The time now is 11:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com