Changing chart references as the months passes

D_Holmes

New Member
Joined
Sep 18, 2020
Messages
32
Office Version
  1. 2013
Platform
  1. Windows
Hi All,

I am trying to create a macro that updates three different charts with information based on data from a specific sheet. I cannot figure out what the VBA name for the specific charts are or excel is changing them as I go (not sure how that works), but the charts keep getting jumbled up. Here is the code I have written so far:

If Worksheets("09_2020").Visible = True Then

Worksheets("Dashboard").Select
Charts(1).Activate
ActiveChart.Parent.Name = "Type of Event"
With ActiveChart
.SetSourceData Source:=Worksheets("09_2020").Range("R2:S6")
.SetElement (msoElementDataLabelCallout)
.SetElement (msoElementLegendRight)
End With

Charts(2).Activate
ActiveChart.Parent.Name = "Position"
With ActiveChart
.SetSourceData Source:=Worksheets("09_2020").Range("T2:U9")
.SetElement (msoElementDataLabelCallout)
.SetElement (msoElementLegendNone)
End With

Charts(3).Activate
ActiveChart.Parent.Name = "Location"
With ActiveChart
.SetSourceData Source:=Worksheets("09_2020").Range("X2:Y6")
.SetElement (msoElementDataLabelCallout)
.SetElement (msoElementLegendNone)
End With
End If

I will create a series of the above code to reference sheets with dates til June 2021.

All help is greatly appreciated.

Thank you.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
If there are only the three, the following post will cycle through each one.
 
Upvote 0

Forum statistics

Threads
1,214,523
Messages
6,120,033
Members
448,940
Latest member
mdusw

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