0

This is a follow up to this question: Python win32com PivotCache.CreatePivotChart() error: 'Exception occurred'

I have 2 Pivot Tables on 1 sheet, and whenever I try to create a Pivot Chart for the Second Pivot Table, it always uses the First Pivot Table.

The previous question did not show how to specify what Table to use.

if I try this, code, it always uses the Table that is First chart = ws2.Shapes.AddChart2(276, xlAreaStacked)

I recorded a excel macro and this is what it showed ActiveChart.SetSourceData Source:=Range("Sheet3!TorquePivotTable")

However I'm not sure how to convert that line into something python likes, since there is a space between "SetSourceData Source:"

1 Answers1

0

ok, after about 3+ hours of additional time messing with this, turns out all you have to do is select a cell inside the Pivot Table you want to use, THEN add the chart.... so:

    ws2.Range('A13').Select()
    chart = ws2.Shapes.AddChart2(276, xlAreaStacked)