Changing chart references as the months passes

D_Holmes

New Member
Joined
Sep 18, 2020
Messages
25
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.
 

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

C Moore

Well-known Member
Joined
Jan 17, 2014
Messages
540
Office Version
  1. 365
Platform
  1. Windows
If there are only the three, the following post will cycle through each one.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,098
Messages
5,545,948
Members
410,713
Latest member
TaremyLunsil
Top