Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dear experts,
I would like to insert a chart in a spreadsheet automatically with VBA. The chart refers to 4 ranges in rows, each range is a different data serie. Sometimes it might be that a whole serie has no data in it - so I get an error from VBA. I have bypassed it by stating "On error resume next", but it has the disadvantage that instead of getting in the legend the name of serie where there are no data, I only get "serie 3" or "serie 4"... quite awful in a chart! Is there a way I can get the name of the serie even if it contains no data? Many thanks in advance! Best regards, Valeria In case it might help, here is my code: ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range ("A20"), PlotBy:= _ xlRows ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection(1).XValues = X_Data ActiveChart.SeriesCollection(1).Values = Tot_Cost ActiveChart.SeriesCollection(1).Name = Workbooks (Product).Worksheets(1).Cells(ProductLastRow + 1, 4) ActiveChart.SeriesCollection(2).Values = Int_Cost ActiveChart.SeriesCollection(2).Name = Workbooks (Product).Worksheets(1).Cells(ProductLastRow + 2, 4) ActiveChart.SeriesCollection(3).Values = Ext_Cost On Error Resume Next ActiveChart.SeriesCollection(3).Name = Workbooks (Product).Worksheets(1).Cells(ProductLastRow + 3, 4) ActiveChart.SeriesCollection(4).Values = Price_Data On Error Resume Next ActiveChart.SeriesCollection(4).Name = Workbooks (Product).Worksheets(1).Cells(ProductLastRow + 7, 4) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
charts toolbar / charts disappeared | Charts and Charting in Excel | |||
link excel charts to web pages and update charts automatically | Charts and Charting in Excel | |||
Charts - How to have multiple charts share a legend. | Charts and Charting in Excel | |||
interactive charts for stacked bar charts | Charts and Charting in Excel | |||
Matching the colors Column Charts and Pie Charts | Charts and Charting in Excel |