Task: Change the time in the pivot table according to the latest update of the table. Example: Last update was at 3:00 pm, 15 is displayed in cell J2 (the ЧАС() function). You should get something like this macro record:
ThisWorkbook.Sheets("Stat Today").PivotTables("СводнаяТаблица13").PivotFields( _ "[Time HH].[Time by Periods].[Period]").VisibleItemsList = Array( _ "[Time HH].[Time by Periods].[Period].&[Night]") ThisWorkbook.Sheets("Stat Today").PivotTables("СводнаяТаблица13").PivotFields( _ "[Time HH].[Time by Periods].[H]").VisibleItemsList = Array( _ "[Time HH].[Time by Periods].[H].&[9]", "[Time HH].[Time by Periods].[H].&[10]", _ "[Time HH].[Time by Periods].[H].&[11]", "[Time HH].[Time by Periods].[H].&[12]" _ , "[Time HH].[Time by Periods].[H].&[13]", _ "[Time HH].[Time by Periods].[H].&[14]", "[Time HH].[Time by Periods].[H].&[15]" _ ) My code does not work, although it does not issue errors
Dim N As Integer Dim M As Integer N = ThisWorkbook.Sheets("Stat Today(MainSources)").Cells(2, 10).Value M = 8 Do Until M > N ThisWorkbook.Sheets("Stat Today").PivotFields( _ "[Time HH].[Time by Periods].[Period]").VisibleItemsList = Array( _ "[Time HH].[Time by Periods].[Period].&[Night]") ThisWorkbook.Sheets("Stat Today").PivotFields( _ "[Time HH].[Time by Periods].[H]").VisibleItemsList = Array( _ "[Time HH].[Time by Periods].[H].&[M]") M = M + 1 Loop
M = 8? IfN = 15, then the conditionM > Nwill not be executed, respectively, the code works, but does nothing but assignment - slippyk