ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programatically changing the chart datapoints (https://www.excelbanter.com/excel-programming/316982-programatically-changing-chart-datapoints.html)

ams

Programatically changing the chart datapoints
 
Guys,
I am having an excel template with a chart having 15 pre-defined
datapoints. I am trying to set the co-ordinates of the datapoints
depending upon the data entered, through a micro. It throughs user an
error "Unable to get series collection property of chart class". I
found that, when user use this template, the datapoint somehow get
deleted, which might be leading to this error. Any help is
appreciated. Pasting the code here for your reference.

------------
Do Until (dataID = 19) s
Charts("Chart Q1").SeriesCollection(dataID).Name =
Sheets(3).Range("B" & sheet3Count)' This is where error points
If (IsError(Sheets(3).Range("G" & sheet3Count + 1)) Or
IsError(Sheets(3).Range("G" & sheet3Count + 2)) Or
IsEmpty(Sheets(3).Range("G" & sheet3Count + 1)) Or
IsEmpty(Sheets(3).Range("G" & sheet3Count + 2)) Or foundOverAll =
True) Then
Charts("Chart Q1").SeriesCollection(dataID).Values = 1
Charts("Chart Q1").SeriesCollection(dataID).XValues = -1
Charts("Chart Q1").SeriesCollection(dataID).MarkerSize = 2
Else
Charts("Chart Q1").SeriesCollection(dataID).Values =
Sheets(3).Range("G" & sheet3Count + 1)
Charts("Chart Q1").SeriesCollection(dataID).XValues =
Sheets(3).Range("G" & sheet3Count + 2)
Charts("Chart Q1").SeriesCollection(dataID).MarkerSize = 18
End If

If (Sheets(3).Range("B" & sheet3Count) = "Overall") Then
Charts("Chart Q1").SeriesCollection(dataID).MarkerStyle =
xlSquare
Charts("Chart
Q1").SeriesCollection(dataID).MarkerBackgroundColo rIndex = 1
foundOverAll = True
Else
Charts("Chart Q1").SeriesCollection(dataID).MarkerStyle =
xlCircle
Charts("Chart
Q1").SeriesCollection(dataID).MarkerBackgroundColo rIndex = xlAutomatic
End If

dataID = dataID + 1
sheet3Count = sheet3Count + 4

Loop


All times are GMT +1. The time now is 03:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com