Happy holidays MR.Excel users!
I've hit a little snag in filtering this pivot table report. I marked in red my problem area.. not sure why but it is giving me different errors depending on the date format but either way it does not work. Any suggestions on how to make it work? My latest trial i used format "Short Date" and it gave me 1004 runtime error. Everything works up until that point. The textboxes are on a userform if that changes anything, and I am using excel 2013.
I've hit a little snag in filtering this pivot table report. I marked in red my problem area.. not sure why but it is giving me different errors depending on the date format but either way it does not work. Any suggestions on how to make it work? My latest trial i used format "Short Date" and it gave me 1004 runtime error. Everything works up until that point. The textboxes are on a userform if that changes anything, and I am using excel 2013.
Code:
starr = Format(Me.tbStartDate.Text, "Short Date")
endd = Format(Me.tbEndDate.Text, "Short Date")
For Each ws In wbReport.Sheets
For Each pt In ws.PivotTables
For Each pi In pt.PivotFields("People").PivotItems
If pi.Name <> person Then
pi.Visible = False
ElseIf pi.Name = person Then
pi.Visible = True
End If
Next pi
[COLOR=#ff0000] pt.PivotFields("Date").PivotFilters.Add2 Type:=xlDateBetween, Value1:=starr, Value2:=endd[/COLOR]
Next pt
Next ws