Hey Everyone,
I wrote a program that creates a report from a simple Excel database and it includes a pivotchart/table. Basically, it works by copying the relevant sheets from the database to a new workbook.
Anyway, I'm having trouble copying a pivot chart. As it's coded now, the chart is copied as a regular chart and i lose the functionality of a pivot. The pivot table copies fine, though.
The relevant code is as follows:
Set Ws1 = ThisWorkbook.Sheets("Daily Report")
Set Ws3 = ThisWorkbook.Sheets("Database")
Set Ws4 = ThisWorkbook.Sheets("Bypass Data Table")
Set Ws5 = ThisWorkbook.Sheets("Bypass History")
Set Wbk1 = ActiveWorkbook
ReportDate = ThisWorkbook.Sheets("Daily Report").Cells.Range("I1").Value
Workbooks.Add
Set Wbk2 = ActiveWorkbook
Set Ws2 = Wbk2.Sheets("Sheet1")
Ws2.Activate
ActiveWindow.DisplayGridlines = False
'Copy all the worksheets
Ws1.Copy before:=Ws2
Ws5.Copy after:=Ws2
Ws4.Copy after:=Ws2
Ws3.Copy after:=Ws2
'Hide the Database
Wbk2.Sheets("Database").Visible = False
I'm sure it's something really simple, but I haven't been able to figure it out.
Cheers,
-H.
I wrote a program that creates a report from a simple Excel database and it includes a pivotchart/table. Basically, it works by copying the relevant sheets from the database to a new workbook.
Anyway, I'm having trouble copying a pivot chart. As it's coded now, the chart is copied as a regular chart and i lose the functionality of a pivot. The pivot table copies fine, though.
The relevant code is as follows:
Set Ws1 = ThisWorkbook.Sheets("Daily Report")
Set Ws3 = ThisWorkbook.Sheets("Database")
Set Ws4 = ThisWorkbook.Sheets("Bypass Data Table")
Set Ws5 = ThisWorkbook.Sheets("Bypass History")
Set Wbk1 = ActiveWorkbook
ReportDate = ThisWorkbook.Sheets("Daily Report").Cells.Range("I1").Value
Workbooks.Add
Set Wbk2 = ActiveWorkbook
Set Ws2 = Wbk2.Sheets("Sheet1")
Ws2.Activate
ActiveWindow.DisplayGridlines = False
'Copy all the worksheets
Ws1.Copy before:=Ws2
Ws5.Copy after:=Ws2
Ws4.Copy after:=Ws2
Ws3.Copy after:=Ws2
'Hide the Database
Wbk2.Sheets("Database").Visible = False
I'm sure it's something really simple, but I haven't been able to figure it out.
Cheers,
-H.