Been trying to figure out what the reason caused the "Invalid Parameter" error for the past 20 minutes... and still clueless. Anyway, In my worksheet I have 2 charts. In my VBA code, I defined both chart with individual seriescollection (SeriesCollection(1) for chart one and SeriesCollect(2) for chart two). However, I kept getting the Invalid Parameter at line ChtObjTELCO.Chart.SeriesCollection(2).Values = Range(Cells(UserRow, 8), Cells(UserRow, 9)) and to be honest, I can't figure it out why.
Any help is appreciated.
Below is my code and I have attached a sample workbook
Sub UpdateChart()
Dim ChtObjEnt As ChartObject, ChtObjTELCO As ChartObject
Dim UserRow As Integer
Set ChtObjEnt = ActiveSheet.ChartObjects(1)
Set ChtObjTELCO = ActiveSheet.ChartObjects(2)
UserRow = ActiveCell.Row
If UserRow < 19 Or IsEmpty(Cells(UserRow, 3)) Then
ChtObjEnt.Visible = False
Else
ChtObjEnt.Chart.SeriesCollection(1).Values = Range(Cells(UserRow, 3), Cells(UserRow, 4))
ChtObjEnt.Chart.ChartTitle.Text = Cells(UserRow, 1).Text
ChtObjEnt.Visible = True
ChtObjTELCO.Chart.SeriesCollection(2).Values = Range(Cells(UserRow, 8), Cells(UserRow, 9)) 'Error Line
ChtObjTELCO.Chart.ChartTitle.Text = Cells(UserRow, "F").Text
ChtObjTELCO.Visible = True
End If
End Sub
Bookmarks