hello
i have this code but i no know what's the problem
if i filter data besd on name in h1 it's ok but if i select the only month in i1
or select name and month h1,i1 it alway show the message box
by the way format date mm/dd/yyyy
Sub test()
Dim myMonth, myMonths, myName, txt As String
myMonths = Array("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec")
Sheets("result").UsedRange.Clear
With Sheets("data").Cells(1).CurrentRegion
.Rows(1).Copy Sheets("master").Cells(1)
myMonth = Application.Match(.Parent.Range("i1"), myMonths, 0)
If IsNumeric(myMonth) Then txt = "year(a2)=year(today()),month(a2)=" & myMonth
If .Parent.[h1] <> "" Then txt = txt & IIf(txt <> "", ",", "") & "b2=h$1"
If Len(txt) Then .Parent.[m2].Formula = "=and(" & txt & ")"
.AdvancedFilter 2, .Parent.[m1:m2], Sheets("master").Cells(1).CurrentRegion
.Parent.[m2].Clear
If Sheets("master").Cells(1).CurrentRegion.Rows.Count = 1 Then
MsgBox "No data found": Exit Sub
End If
Sheets("master").Select
End With
End Sub
please if anybody can help me