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