I am using an auto filter criteria range, where the cells reference filter selections input on a different tab. For example, the cells in the criteria range have a formula similar to this:
=if(Sheet1!A1="","",Sheet1!A1)
However, if only 1 of the 4 input selections are chosen (which is often the case), when I run the auto-filter all lines are hidden. For example, I want to see all lines of data for the month of January:
Filter on Department: <blank>
Filter on Year: <blank>
Filter on Month: JAN
Filter on Description: <blank>
Unless there is a selection for all 4, all lines are hidden. I think it is because it is looking to filter on cells that have "", which of course nothing in the filter range has. Is there another way to either write the if formula, or a way to tell the auto-filter to ignore blank cells (that aren't really 'blank", because they have the "" in them)?
If I remove the formula in the cells that have no selection, the auto-filter works fine but that kind of defeats the purpose. The code I'm using is:
=if(Sheet1!A1="","",Sheet1!A1)
However, if only 1 of the 4 input selections are chosen (which is often the case), when I run the auto-filter all lines are hidden. For example, I want to see all lines of data for the month of January:
Filter on Department: <blank>
Filter on Year: <blank>
Filter on Month: JAN
Filter on Description: <blank>
Unless there is a selection for all 4, all lines are hidden. I think it is because it is looking to filter on cells that have "", which of course nothing in the filter range has. Is there another way to either write the if formula, or a way to tell the auto-filter to ignore blank cells (that aren't really 'blank", because they have the "" in them)?
If I remove the formula in the cells that have no selection, the auto-filter works fine but that kind of defeats the purpose. The code I'm using is:
Code:
Sub AutoFilter2()
Dim rngCritLabor As Range
Dim rngFilterLabor As Range
With Sheets("Labor")
Set rngCritLabor = .Range("Filter_Crit_Labor")
Set rngFilterLabor = .Range("Filter_Data_Labor")
End With
rngFilterLabor.AdvancedFilter _
Action:=xlFilterInPlace, _
criteriarange:=rngCritLabor
End Sub