W
WilliamI
On a worksheet, I have a List Box Control (lbProfitICSales) with a
ListFillRange named "Profit_Ind_Cd_Sales". When selecting an item in the List
Box, I want to change the x and y data series in the single chart on the
"Profit-Ind Cd Sales" worksheet. I don't understand why the following code
does not work- I always get an "object does not support this property or
method". Help lookup indicates this code should work.
Private Sub lbProfitICSales_Change()
Dim strwksht As String
strwksht = Application.ActiveSheet.Name
'Worksheets("Review").Unprotect
'Worksheets(strwksht).Activate
With Worksheets(strwksht).ChartObjects(1).Chart
.HasTitle = True
.ChartTitle.Text = "Profit by Industry Code Sales Regression"
Select Case lbProfitICSales
Case "Comb GP"
.SeriesCollection(1).Name = "Comb GP"
.SeriesCollection(1).XValues = Worksheets(strwksht)!Range("C10:C65")
.SeriesCollection(1).Values = Worksheets(strwksht)!Range("U10:U65")
Case "Comb PAD"
.SeriesCollection(1).Name = "Comb PAD"
.SeriesCollection(1).XValues = Worksheets(strwksht)!Range("E10:E65")
.SeriesCollection(1).Values = Worksheets(strwksht)!Range("E10:E65")
Case "Comb OP"
.SeriesCollection(1).Name = "Comb OP"
.SeriesCollection(1).XValues = Worksheets(strwksht)!Range("G10:G65")
.SeriesCollection(1).Values = Worksheets(strwksht)!Range("W10:W65")
End Select
End With
End Sub
ListFillRange named "Profit_Ind_Cd_Sales". When selecting an item in the List
Box, I want to change the x and y data series in the single chart on the
"Profit-Ind Cd Sales" worksheet. I don't understand why the following code
does not work- I always get an "object does not support this property or
method". Help lookup indicates this code should work.
Private Sub lbProfitICSales_Change()
Dim strwksht As String
strwksht = Application.ActiveSheet.Name
'Worksheets("Review").Unprotect
'Worksheets(strwksht).Activate
With Worksheets(strwksht).ChartObjects(1).Chart
.HasTitle = True
.ChartTitle.Text = "Profit by Industry Code Sales Regression"
Select Case lbProfitICSales
Case "Comb GP"
.SeriesCollection(1).Name = "Comb GP"
.SeriesCollection(1).XValues = Worksheets(strwksht)!Range("C10:C65")
.SeriesCollection(1).Values = Worksheets(strwksht)!Range("U10:U65")
Case "Comb PAD"
.SeriesCollection(1).Name = "Comb PAD"
.SeriesCollection(1).XValues = Worksheets(strwksht)!Range("E10:E65")
.SeriesCollection(1).Values = Worksheets(strwksht)!Range("E10:E65")
Case "Comb OP"
.SeriesCollection(1).Name = "Comb OP"
.SeriesCollection(1).XValues = Worksheets(strwksht)!Range("G10:G65")
.SeriesCollection(1).Values = Worksheets(strwksht)!Range("W10:W65")
End Select
End With
End Sub