Automate Chart

riedyp

Board Regular
Joined
Feb 13, 2020
Messages
88
Office Version
  1. 365
Platform
  1. Windows
Hello,
I am trying to use data that is displayed in this chart in columns R to V. However I want to only include rows that have a value displayed in my data for my Gantt chart. I am trying to figure out how to insert the correct data in vba and was wondering if I could get some help because this is beyond my knowledge at this point.

Here is my current code:
VBA Code:
Private Sub Worksheet_Calculate()
Dim ch As ChartObject
Set ch = Worksheets("Executive Summary").ChartObjects("Chart 7")
UpdateRow = Worksheets("Executive Summary").Cells(Rows.Count, 17).End(xlUp).Row 'Only select data that is displayed
ch.Chart.Axes(xlValue).MinimumScale = [T2]
ch.Chart.Axes(xlValue).MaximumScale = [U2]
ch.Chart.SetSourceData Source:=Worksheets("Executive Summary").Range(Cells(3, 19), Cells(UpdateRow, 19))


End Sub
 

Attachments

  • update.PNG
    update.PNG
    71.8 KB · Views: 4
  • display.PNG
    display.PNG
    75.9 KB · Views: 4
  • display2.PNG
    display2.PNG
    73.9 KB · Views: 3

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
I think you need to alter both series, like this:

VBA Code:
Dim ch As ChartObject
Set ch = Worksheets("Executive Summary").ChartObjects("Chart 7")
UpdateRow = Worksheets("Executive Summary").Cells(Rows.Count, 17).End(xlUp).Row 'Only select data that is displayed
ch.Chart.Axes(xlValue).MinimumScale = [T2]
ch.Chart.Axes(xlValue).MaximumScale = [U2]
 
ch.Chart.FullSeriesCollection(1).Formula = _
        "=SERIES('Executive Summary'!R3C20,'Executive Summary'!R4C19:R" & UpdateRow & "C19,'Executive Summary'!R4C20:R" & UpdateRow & "C20,1)"
ch.Chart.FullSeriesCollection(2).Formula = _
        "=SERIES('Executive Summary'!R3C22,'Executive Summary'!R4C19:R" & UpdateRow & "C19,'Executive Summary'!R4C22:R" & UpdateRow & "C22,2)"
 

Watch MrExcel Video

Forum statistics

Threads
1,109,009
Messages
5,526,258
Members
409,689
Latest member
martin_br

This Week's Hot Topics

Top