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