Hello,
I would like to ask you about issue with excel, i am having.
In worksheet, i have two options, to be chosen by user, each option add additional data series in chart.
The problem is that there is combination between both options and VBA in default create data series according to indexes. Therefore if there is placed only the 1st option, it adds SeriesCollection(6), if there are chosen both options, the 1st option add SeriesCollection(6), the 2nd option add SeriesCollection(7). However the problem is when i want to choose only the 2nd option and the 1st is blank, excel creates the 2nd option as seriescollection(6), but I need it to be remained as SeriesCollection(7) or somehow have its own fixed name, which I can refer to.
Am i somehow able to set up the 1st option as SeriesCollection 6 and the 2nd option as SeriesCollection(7), regardless it was chosen or not?
I know i can use SeriesCollection.Count to test how many collections are in chart and process the code, but more suitable would be to have fixed series collections of each option to be placed optionally.
Option1
Option2
Thank you for help
I would like to ask you about issue with excel, i am having.
In worksheet, i have two options, to be chosen by user, each option add additional data series in chart.
The problem is that there is combination between both options and VBA in default create data series according to indexes. Therefore if there is placed only the 1st option, it adds SeriesCollection(6), if there are chosen both options, the 1st option add SeriesCollection(6), the 2nd option add SeriesCollection(7). However the problem is when i want to choose only the 2nd option and the 1st is blank, excel creates the 2nd option as seriescollection(6), but I need it to be remained as SeriesCollection(7) or somehow have its own fixed name, which I can refer to.
Am i somehow able to set up the 1st option as SeriesCollection 6 and the 2nd option as SeriesCollection(7), regardless it was chosen or not?
I know i can use SeriesCollection.Count to test how many collections are in chart and process the code, but more suitable would be to have fixed series collections of each option to be placed optionally.
Option1
Rich (BB code):
Rich (BB code):
If Worksheets("main").Range("c44") = "option1" Then
ActiveSheet.ChartObjects("Graf 10").Activate
Application.CutCopyMode = False
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(6).Values = _
"=data"
ActiveChart.SeriesCollection(6).Select
ActiveChart.SeriesCollection(6).AxisGroup = 2
ActiveChart.SeriesCollection(6).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(255, 0, 0)
End With
End if
Option2
Rich (BB code):
Rich (BB code):
Rich (BB code):
If Worksheets("main").Range("F44") = "Option2“ Then
ActiveSheet.ChartObjects("Graf 10").Activate
Application.CutCopyMode = False
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(7).Values = _
"=data2"
ActiveChart.SeriesCollection(7).Select
ActiveChart.SeriesCollection(7).AxisGroup = 2
ActiveChart.SeriesCollection(7).Select
With Selection.Format.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(155, 0, 0)
End With
End If
Thank you for help