graph in vba does not appear

camper12
camper12 used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Retired
Top Expert 2012
Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial