graph in vba does not appear

Hi,

PFB my code. I have no clue why the graph is not appearing with my code.

Dim ws As Worksheet
   On Error Resume Next


    ActiveSheet.Shapes.AddChart
    ActiveChart.ChartType = xlLine
    
   ActiveSheet.Shapes("Chart 5").IncrementLeft -5.25
    ActiveSheet.Shapes("Chart 5").IncrementTop 99
    ActiveChart.ChartArea.Select
    ActiveChart.SeriesCollection.XValues = RngX
    ActiveChart.SeriesCollection(1).XValues = RngX
    ActiveChart.ChartArea.Select
    ActiveChart.HasAxis(xlTimeScale) = True
    ActiveChart.Axes(xlCategory).Select
    ActiveChart.Axes(xlCategory).CategoryType = xlCategoryScale
    ActiveChart.SeriesCollection(1).XValues = RngX
    For i = 1 To UBound(InputRecords, 1)
    ActiveChart.SeriesCollection.NewSeries
    If i = 1 Then
    ActiveChart.SeriesCollection(i).Name = ws.Cells(10, 3)
    Set RngY = ws.Range(ws.Cells(11, 2), ws.Range(ws.Cells(, 3) & Cells.Rows.Count).End(xlUp))
    ActiveChart.SeriesCollection(i).Values = RngY
    Else
    ActiveChart.SeriesCollection(i).Name = ws.Cells(10, i * 2)
    Set RngY = ws.Range(ws.Cells(11, 2), ws.Range(ws.Cells(, i * 2) & Cells.Rows.Count).End(xlUp))
    ActiveChart.SeriesCollection(i).Values = RngY
    End If
  Next i

Open in new window

camper12Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
There are two many items undeclared and/or values not set to make a definite diagnosis, but first, remove the 'On Error Resume Next' line. That way you will know as soon as an error arises.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.