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

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,213,539
Messages
6,114,221
Members
448,554
Latest member
Gleisner2

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