VBA to filter date by year and month in cell data

Turbo68

Board Regular
Joined
Jan 31, 2014
Messages
118
I am wanting to get a report created by using my customer data info in a sheet(customers) that is filtered by selected YEAR(name range "YR") and Month(named range "MN". I have 2 dropdowns for those named ranges so when you select the year and then a month I have a button that execute the macro and copies that data and pastes it for printing in my report sheet. Here is what i have "kinda working" : ( i know its crude basic stuff :) )


Sub Macro3()
'
' Macro3 Macro
'

'
Sheets("Customers").Select

If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
Range("A2").Select

ActiveSheet.Range("$A$1:$P$2400").AutoFilter Field:=14, Operator:= _
xlFilterValues, Criteria2:=Array(1, "MN/YR")
Selection.End(xlUp).Select

Range("Big_Data").Select
Selection.Copy

Sheets("Reports").Select
Range("A8").Select
ActiveSheet.Paste


Sheets("Customers").Select
If (ActiveSheet.AutoFilterMode And ActiveSheet.FilterMode) Or ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If

Sheets("Reports").Select
End Sub

If I put JAN/20 where the MN/YR is it will report January 2021 data?

Any help would be appreciated.

M
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I think you should provide sample on how data looks like to get reply.
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,065
Members
448,942
Latest member
sharmarick

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