baldmosher
New Member
- Joined
- Jul 10, 2009
- Messages
- 32
Excel 2010
I'm trying to update a chart source data range with VBA but it's pulling in the wrong range.
where the data source is "graph_01" because it's January data (stats per day, grouped 1 month per table):
So.... nm and rG and Selection all refer to "=York!$A$7:$X$7,York!$A$10:$X$11"
however when it comes to the next line....
Excel is inexplicably loading the source data range as: =York!$A$7:$X$8,York!$A$11:$X$11
If I try to specify the source data range manually, via right-click > Select Data, it makes no difference, it still changes it back!
Any clues as to why Excel is being demented? I'm assuming the fact that I'm spanning multiple ranges has something to do with it. If so is there a common fix/workaround?
I'm trying to update a chart source data range with VBA but it's pulling in the wrong range.
where the data source is "graph_01" because it's January data (stats per day, grouped 1 month per table):
Code:
Set rG = rH.Cells(1) 'first cell in header row
Set rG = Range(rG, rG.End(xlToRight)) '...to last cell in header row
Set rG = Union(rG, rG.Offset(3), rG.Offset(4)) 'include the two rows of data relevant to the chart
Set nm = ActiveSheet.Names.Add("graph_01", rG) 'add the range name "graph_01"
rG.Select 'just for debugging
So.... nm and rG and Selection all refer to "=York!$A$7:$X$7,York!$A$10:$X$11"
however when it comes to the next line....
Code:
ActiveSheet.ChartObjects("Chart_01").Chart.SetSourceData rG, xlRows
Excel is inexplicably loading the source data range as: =York!$A$7:$X$8,York!$A$11:$X$11
If I try to specify the source data range manually, via right-click > Select Data, it makes no difference, it still changes it back!
Any clues as to why Excel is being demented? I'm assuming the fact that I'm spanning multiple ranges has something to do with it. If so is there a common fix/workaround?
Last edited: