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

excel charts using vba

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

Excel Charts using VBA

ResolvedVersion 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:

Create your own custom list on Excel 2010!

If you know how to use the auto-fill option on Excel then why not create your own customs lists?

The auto fill feature saves you time by allowing you to enter one of the list entries into a cell and then use your mouse to automatically drag the rest of the list into the cells below, above or to either side of the initial cell. When using your mouse to perform this task you will see a thin black cross appear at the bottom right hand side of the cell. Click, hold and drag to make the list appear.

Default lists include weekdays and months. To create your own list in Excel 2010 do the following;

>File
>Options
>Advanced
>Scroll right to the bottom of the page and you will see a buttom "edit custom lists", click this button
>enter your list in the list entries
>click add

Now try it out. Good luck.
>

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.