Filtering between two dates in pivot table using VBA. UK to US date format issue

后端 未结 2 1537
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 07:33

I have found a workaround for this but if anyone has a cleaner way of doing this I\'d be interested/grateful.

I have two boxes on a spreadsheet, called DateFrom and

2条回答
  •  伪装坚强ぢ
    2020-12-10 08:07

    Indeed, this is strange. I've reproduced your issue with Excel 2007 and German locale settings.

    However, when converting the date values to Longs using CLng, everything works:

    ActiveSheet.PivotTables("Pivot").PivotFields("Date").PivotFilters. _
    Add Type:=xlDateBetween, Value1:=CLng(Range("DateFrom").Value), Value2:=CLng(Range("DateTo").Value)
    

提交回复
热议问题