Microsoft Office Tutorials and References
In Depth Information
Creating a PPT Presentation from a Pivot Chart
With PivotData¶
Avg = 0¶
'calculate the total of elements first¶
Avg = Application.CountIf(.Columns(1), PItem.Caption)¶
'If some exist, calculate the average, if not, it's 0¶
If Avg > 0 Then¶
Avg = Application.SumIf(.Columns(1), PItem.Caption, _¶
.Columns(4)) / Avg¶
Else¶
Avg = 0¶
End If¶
End With¶
'Add the text¶
With pAvg.TextFrame.TextRange¶
.Text = "Average of '" & PItem.Caption & "' is: " & _¶
Format$(Avg, "currency")¶
.Font.Bold = True¶
.Font.Size = 12¶
End With¶
End If¶
Next PItem¶
'Restore screen updating¶
Application.ScreenUpdating = True¶
'Activate and display PowerPoint¶
pPoint.Visible = True¶
pPoint.ActiveWindow.ViewType = 1 'ppViewSlide = 1¶
pPoint.Activate¶
'Destroy the variables¶
Set pShape = Nothing¶
Set pSlide = Nothing¶
Set pPres = Nothing¶
Set pPoint = Nothing¶
End Sub¶
Exl
This macro uses the pivot table in sample E032.xls. It should also work with a
different pivot chart if you change the reference to it in the code and remove
the code that creates the average of the field, unless it provides useful
information.
Search JabSto ::




Custom Search