Need Assistance adding a second series to an excel chart with VB.Net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MitchR
    New Member
    • Oct 2006
    • 65

    Need Assistance adding a second series to an excel chart with VB.Net

    Hello all! I am in need of some guidance .... please! I am able to place a single series of chart data with my code but I cannot for the life of me figure out how to add a second series. I can add the Series ... I can Select the series but cannot with out errors figure out how to put data the the series' that I am creating ... PLEASE Help! Thank you in advance

    Ol' Mitch

    xlApp.ActiveCha rt.SeriesCollec tion(1).Values = Rng1 <-- Error


    xlApp.ActiveCha rt.SeriesCollec tion(2).Values = Rng2 <-- Error

    Code:
     Rng1 = xlApp.ActiveSheet.Range("B501:C511")
                
               Rng2 = xlApp.ActiveSheet.Range("E501:F505")
    
    
                xlApp.ActiveSheet.ChartObjects.Add(75, 180, 815, 200).Select()
                xlApp.ActiveChart.ChartStyle = 42
    
                xlApp.ActiveChart.SeriesCollection.NewSeries()
                xlApp.ActiveChart.SeriesCollection.NewSeries()
    
                
                xlApp.ActiveChart.SeriesCollection(1).Select()
                xlApp.ActiveChart.SeriesCollection(1).Values = Rng1 <--Error 
    
                xlApp.ActiveChart.SeriesCollection(2).Select()
                xlApp.ActiveChart.SeriesCollection(2).Values = Rng2 <-- Error
    
    
                xlApp.ActiveChart.HasTitle = True
                xlApp.ActiveChart.ChartTitle.Characters.Text = "Title"
Working...