Trying filter multiple columns

gmcollins

New Member
Joined
Aug 23, 2017
Messages
8
I am new to Excel vba and am trying to filter records based on certain column selection. 1st I would like to filter out all #Div/0 errors and 2nd I would like to filter for only records ">=" a user input box. I'm using the following code:

Dim StartDate As Long
Dim temp As String

temp = Application.InputBox("Enter Last Rate Increase Run Date in the Format ""MM/DD/YYYY""")
StartDate = CLng(DateValue(temp))
Application.ScreenUpdating = False
ActiveSheet.AutoFilterMode = False
Dim LastRow As Long, FilterRange As Range


ActiveSheet.Range("$AC3:$AH").AutoFilter Field:=1, Criteria1:="<>#DIV/0!", Operator:=xlAnd, Field:=6, Criteria2:=">" & StartDate


I am getting a Runtime Error 1004: "application defined or object defined error" on the last line. What do I have incorrect?

Thank you to all the wonderful help on this site that helped me get this far.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi

You cannot mix multiple fields in the same autofilter statement.

This is an example:

Code:
Sub Test()
Dim StartDate As Date

StartDate = Date

ActiveSheet.AutoFilterMode = False

With ActiveSheet.Range("$AC3:$AH100")

    .AutoFilter Field:=1, Criteria1:="<>#DIV/0!"
    .AutoFilter Field:=6, Criteria1:=">" & StartDate

End With

End Sub
 
Last edited:
Upvote 0
Hi

You cannot mix multiple fields in the same autofilter statement.

This is an example:

Code:
Sub Test()
Dim StartDate As Date

StartDate = Date

ActiveSheet.AutoFilterMode = False

With ActiveSheet.Range("$AC3:$AH100")

    .AutoFilter Field:=1, Criteria1:="<>#DIV/0!"
    .AutoFilter Field:=6, Criteria1:=">" & StartDate

End With

End Sub

Thank you PGC, this is starting to work. When I get to:


.AutoFilter Field:=6, Criteria1:=">" & StartDate

I get Runtime error 1004 - AutoFilter method of Range class failed?

You are a life saver helping me get this far. thank you again.
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top