excel vba charts

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 VBA - Charts

Excel VBA - Charts

resolvedResolved · Low Priority · Version 2003

Michael has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Access VBA course

Excel VBA - Charts

Is it possible to amend the 'source data' range with VBA when constructing/updating excel charts ?

RE: Excel VBA - Charts

Hi Michael,

Thank you for your question. Whenever you wish to change any data, you should set it as a Variable. In this case, SourceData should be set as a range variable.

Assuming your sourcedata always start in cell "A1" of worksheet "Sheet 1", see the sample codes below:

====================================
Sub MakeChart()

Dim SourceData As Range

Set SourceData = Range("A1", Range("A1").End(xlToRight).End(xlDown))

Charts.Add

ActiveChart.SetSourceData Source:=SourceData
ActiveChart.Location Where:=xlLocationAsNewSheet

Sheets("Sheet1").Select

End sub

====================================

Hope this is useful

Kind regards,

Katie Woo
Microsoft Certified Trainer

 

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:

Sorting data stored in rows

Primarily Excel is set up to sort data that is stored in columns rather than rows.

It is possible to get Excel to sort data stored in rows however.

Click in the row you want to sort, or select the cells in the rows you wish to sort.

Go to Data - Sort, then go to the Options button in the bottom left corner of the Sort dialogue box.

View all Excel hints and tips


Server loaded in 0.08 secs.