Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel VBA - Charts
Excel VBA - Charts
Resolved · 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 ?
For upcoming training course dates see: Pricing & availability
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
|
