having issues problem: want loop through pivot table date fields in vba 2010 instead of writing:
activesheet.pivottables("mypivottable").pivotfields( _ "[dim time].[year month day].[date yyyymmdd]").visibleitemslist = array( _ "[dim time].[year month day].[year].&[2015].&[01].&[2015/01/01]", _ "[dim time].[year month day].[year].&[2015].&[01].&[2015/01/02]", _ "and on......... until" "[dim time].[year month day].[year].&[2015].&[01].&[2015/01/19]")`
i write like
dim mnths integer dim days integer mnths = 1 5 days = 1 19 sheets("mtshhet").select activesheet.pivottables("mypivottable").pivotfields( _ "[dim time].[year month day].[date yyyymmdd]").visibleitemslist = array( _ "[dim time].[year month day].[year].&[2015].&[" & mnths & "].&[2015/" & mnths & "/" & days & "])" next days next mnths
i looked around, of explanations saw display different forms of dates not array in example. weird expression date array got while recording macro. guess has pivot table creators (not me).
i can't test final part, can build array this:
dim mnths integer dim days integer dim vdates(1 95) const csdimension string = "[dim time].[year month day].[year].&[2015].&[" mnths = 1 5 days = 1 19 vdates((mnths - 1) * 19 + days) = csdimension & mnths & "].&[2015/" & format$(mnths, "00") & "/" & format$(days, "00") & "])" next days next mnths sheets("mtshhet").pivottables("mypivottable").pivotfields("[dim time].[year month day].[date yyyymmdd]").visibleitemslist = vdates
Comments
Post a Comment