excel charts using vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel Charts using VBA

Excel Charts using VBA

resolvedResolved · Low Priority · Version 2003

Monique has attended:
Excel VBA Intro Intermediate course

Excel Charts using VBA

Is it possible to create charts in Excel using VBA. For example, having created a PivotTable in VBA with yearly totals, can you plot a chart of these values?

RE: Excel Charts using VBA

You can do almost anything in VBA that you can do as an Excel user. The easiest way to find out how the code will look is to record the code of producing the chart and then take a look at the code and work from there.

I recorded creating a chart from a pivot table and got the following code. My pivot table was on Sheet4 and A6 was inside it.

Sub Macro2()
Charts.Add
ActiveChart.SetSourceData Source:=Sheets("Sheet4").Range("A6")
ActiveChart.Location Where:=xlLocationAsNewSheet
End Sub

Formatting the chart to appear as you need is another record a macro and see what it does and tweak it to suit your needs.

Laura GB

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Showing all menu items

If you go into a pull down menu you usally find that you get a selection of items(this is the default) or sometimes everything. If you only get a selectiopn you have to go to the double arrows at the bottom of the menu and click it to get all of the hidden items.
To turn this off so that you always get everything, go to Tools / Customize / Options Tab / "Always show full menus". Make sure there is a tick in the box and you will always have every item.

View all Excel hints and tips


Server loaded in 0.07 secs.