vba courses london - graphics vba
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft VBA Training and help » vba courses london - Graphics in VBA

vba courses london - Graphics in VBA

resolvedResolved · Low Priority · Version Standard

replyReply Fri 19 Jan 2007, 16:40Delegate Nicola said...

Nicola has attended:
Excel VBA Intro Intermediate course

Graphics in VBA

When you have made a pivot table for multiple choices. how do you change the sourced data to a chart rather than a pivot table?

Thanks

For upcoming training course dates see: Pricing & availability

replyReply Fri 26 Jan 2007, 10:13 Edited on Fri 26 Jan 2007, 10:19Trainer Carlos said...

RE: Graphics in VBA

A pivot chart is always created together with a Pivot Table.

If you have created a Pivot Table using VBA code you can do the following:

Add the following code to the end of the routine creating the Pivot Table

OR

Create a separate routine wheck can be called when needed.

Sub CreatePivotChart()

Charts.Add After:=Worksheets("Sales Summary")

'Set the source data by pionting to one of the cells in the Pivot Table
ActiveChart.SetSourceData Source:=Sheets("Sales Summary").Range("A12")

ActiveChart.Location Where:=xlLocationAsNewSheet

ActiveChart.Name = "Pivot Chart"
'If you name the chart as above make sure you check if a chart exists and delete it before creating a new one

End Sub

 

Vba tip:

Good coding practice

It is important that you always comment the VBA code that you write. By doing this it will make the code much easier to read, as both yourself and other people will be able to see what the code is doing or meant to be doing. This is very important if there is more than one person who writes code in the company as you may have different styles of coding and may not really understand what the other person is trying to do. Also if you write some code and then do not touch it for a year or so you may actually forget what it is meant to be doing. so it is very important to include comments throughout your code and try and make sure that they are as useful as possible

View all VBA hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard