help copy filter from sheet to another by using function month name or month

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
994
Office Version
  1. 2010
hello
I need help filter data by using month in c2 like Jan or Feb. ... and so on
I try using function month or month name but I failed
this is my code
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
 
   ' If Not Intersect(Target, Format(Month(Range("c2")), "MM", False)) Is Nothing Then
   If Not Intersect(MonthName(Month(Target, Range("c2").Value), False)) Is Nothing Then
        Sheets("sheet2").Range("A10").CurrentRegion.ClearContents
        Sheets("sheet1").Cells.AutoFilter Field:=1, Criteria1:=Target.Value
        Sheets("sheet1").AutoFilter.Range.Columns("A:q").Copy Sheets("sheet2").Range("A10")
    End If
        Sheets("sheet1").AutoFilterMode = False
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Watch MrExcel Video

Forum statistics

Threads
1,129,515
Messages
5,636,793
Members
416,941
Latest member
shazzaxyz

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
Top