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: 16
  • display.PNG
    display.PNG
    75.9 KB · Views: 13
  • display2.PNG
    display2.PNG
    73.9 KB · Views: 12

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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)"
 
Upvote 0

Forum statistics

Threads
1,224,858
Messages
6,181,431
Members
453,040
Latest member
Santero

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top