Refreshing dynamic secondary axis

tourgis2000

New Member
Joined
Sep 3, 2008
Messages
48
Hi,

I am using Jon Peltier's code to refresh a dynamic chart range as follows:
Code:
Sub UpdateChartSourceData()
  With ActiveSheet
    .ChartObjects(1).Chart.SetSourceData _
        Source:=.Range("ChtSourceData"), _
        PlotBy:=xlColumns
  End With
End Sub
The problem is that I have a secondary axis with a dynamic range that I also need to refresh and I can't find a way to reference it through the seriescollection function. It is not as simple as identifying it as seriescollection(x) by using the macro recorder, because the range on the primary axis is a dynamic range and so I won't know the number. Can anyone help?

Thanks in advance,

Martin
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Thinking further about this I realise that I need to programmatically find the last number in the SeriesCollection and then create the secondary axis from that number +1, something like this:
Code:
Dim m As Integer
mymaxseries=20
For m = 1 To ActiveChart.SeriesCollection.Count etc.
... but I am completely hopeless at VBA. Can someone help me to evaluate the last number? I will then need to refresh the source to the primary axis and then add something like:
Code:
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(m+1).Name = "=""Title"""
ActiveChart.SeriesCollection(m+1).Values = "=DynamicRangeName"
I hope this makes sense; if I can just get this part sorted out I can finish this project!

Thanks

Martin
 
Upvote 0

Forum statistics

Threads
1,215,200
Messages
6,123,612
Members
449,109
Latest member
Sebas8956

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