ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel code from 7 day data to 1 day data-pivot tables (https://www.excelbanter.com/excel-programming/397854-excel-code-7-day-data-1-day-data-pivot-tables.html)

LOrama

Excel code from 7 day data to 1 day data-pivot tables
 
Need to rewrite code for 1 day (24hours) instead of 7 days (24hours)
If (TheDay = "Day 1") Then
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData:= _
"'Day 1'!A:M").CreatePivotTable TableDestination:="", TableName:= _
PTDay11, DefaultVersion:=xlPivotTableVersion10

If (TheDay = "Day 2") Then
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData _
:="'Day 2'!A:M").CreatePivotTable TableDestination:="", TableName _
:=PTDay11, DefaultVersion:=xlPivotTableVersion10

If (TheDay = "Day 3") Then
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData _
:="'Day 3'!A:M").CreatePivotTable TableDestination:="", TableName _
:=PTDay11, DefaultVersion:=xlPivotTableVersion10

If (TheDay = "Day 4") Then
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, _
SourceData:="'Day 4'!A:M").CreatePivotTable TableDestination:="", _
TableName:=PTDay11, DefaultVersion:=xlPivotTableVersion10

If (TheDay = "Day 5") Then
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData _
:="'Day 5'!A:M").CreatePivotTable TableDestination:="", TableName _
:=PTDay11, DefaultVersion:=xlPivotTableVersion10

If (TheDay = "Day 6") Then
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData _
:="'Day 6'!A:M").CreatePivotTable TableDestination:="", TableName _
:=PTDay11, DefaultVersion:=xlPivotTableVersion10

If (TheDay = "Day 7") Then
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatab ase, SourceData _
:="'Day 7'!A:M").CreatePivotTable TableDestination:="", TableName _
:=PTDay11, DefaultVersion:=xlPivotTableVersion10


All times are GMT +1. The time now is 12:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com