PDA

View Full Version : Generate Dynamic Diagram



anghelm
11-07-2011, 05:55 AM
Hello,

I would appreciate if someone could help me with a school project!

I have an excel file containing several columns of various data.
I need add a macro that generates a diagram based on the selected(2) columns.

If i record a macro i get this code:

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Daten'!$A$1:$AS$1825")
ActiveChart.ChartType = xlColumnClustered
ActiveChart.Legend.Select
Selection.Delete
ActiveSheet.ChartObjects("Chart 18").Activate
ActiveChart.ChartArea.Select
ActiveChart.Parent.Delete
Selection.ClearContents
Range("H5").Select

I guess i need to set the parameter of .SetSourceData with the columns, but i don't know how.


Thank you for your help! :)

mdmackillop
11-07-2011, 06:51 AM
Please refer to our FAQ (http://www.vbaexpress.com/forum/faq.php?faq=psting_faq_item#faq_hom_faq_item), Hint: try recording a macro based on 2 selected ranges.