ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I get Bullen's FilterCriteria() to work in Excel 2007? (https://www.excelbanter.com/excel-discussion-misc-queries/180671-how-do-i-get-bullens-filtercriteria-work-excel-2007-a.html)

D4137

How do I get Bullen's FilterCriteria() to work in Excel 2007?
 
I have used Bullen's FilterCriteria VBA function in Excel 2003. But, now I am
using Excel 2007 and the function does not work. The result of the Intersect
function is always = Nothing.
Here is the function for reference:
Public Function FilterCriteria(ByRef Rng As Range) As String
Dim Filter As String
On Error GoTo Finish
Filter = ""
With Rng.Parent.AutoFilter
If Intersect(Rng, .Range) Is Nothing Then
GoTo Finish
End If
With .Filters(Rng.Column - .Range.Column + 2)
If Not .On Then
GoTo Finish
End If
Filter = .Criteria1
Filter = Right$(Filter, Len(Filter) - 1)
Select Case .Operator
Case xlAnd
Filter = Filter & " AND " & .Criteria2
Case xlOr
Filter = Filter & " OR " & .Criteria2
End Select
End With
End With
Finish:
FilterCriteria = Filter
End Function



All times are GMT +1. The time now is 10:15 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com