98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel Charts using VBA
Excel Charts using VBA
Resolved · 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 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
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Showing all menu itemsIf 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. |