Auto Filtering Issues with VBA

BKennelly

New Member
Joined
May 28, 2018
Messages
6
Essentially I am trying to filter Column Z by the months shown in cells B2:B4 upon the click of a button. So let's say that I have May through July showing in Cells B2:B4, once I click a button I want to Auto Filter Column Z to show only the rows that have dates between May and July. I know I could just use the normal filters, however, by doing it through VBA I am thinking that it will not matter which months are showing in B2:B4 and will pull the appropriate data. It sounds simple enough but I am clearly missing something, I have tried a multitude of things across the web and have had no luck so far. Not sure if it matters but I did use a table.

If you need any more information let me know.

Any help would be greatly appreciated.

Thank you,
Brandon




 
I am still getting the Run Time Error 1004 application-defined error.

I originally had the Table3 Range also named Schedule, however I have since removed that and I am still getting the same error, just in case that was messing it up. Could it have anything to do with the fact my data doesn't start until Row 8?

Code:
Sub FilterTableTest()



    Range("Table3[[#Headers],[#Ack. Date]]").Select
    ActiveSheet.ListObjects("Table3").Range.AutoFilter Field:=26, Criteria1 _
        :=">=" & Range("B2"), Operator:=xlAnd, Criteria2:="<=" & Range("B4")
        
End Sub

Thank you,
Brandon
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
No, because of the fact that it is a table.

I tried to PM you but your box is full. Mine was as well. PM me.
 
Upvote 0
After some fiddling around and some accidental code deleting I finally got it to work. Not quite sure how, but it is working. This is the code I ended up using.

Code:
Sub FilterTableTest()

    ActiveSheet.ListObjects("Table3").Range.AutoFilter Field:=26, Criteria1 _
        :=">=" & Range("B2"), Operator:=xlAnd, Criteria2:="<=" & Range("B4")
        
End Sub

Thank you igold for all of your help, and have a good one.
Brandon
 
Upvote 0
I was happy to help. Thanks for the feedback!
 
Upvote 0

Forum statistics

Threads
1,215,032
Messages
6,122,770
Members
449,095
Latest member
m_smith_solihull

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