Avatar of camper12
camper12

asked on 

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

Microsoft ExcelVisual Basic ClassicMicrosoft ApplicationsSpreadsheetsVBA

Avatar of undefined
Last Comment
GrahamSkan
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo