What is the preferred way to anchor an Excel Chart to a named range or other position in a worksheet.
I've got some code that generates a chart and locates it on the worksheet. But some time later when I've added more rows above where the chart is generated, the next time I generate the chart its position overlaps some of my excel calculations.
My thought was to locate the chart relative to a named range; so, that it will always be the same number of rows to that range, even when the worksheet has changed.
Here's the code I've tried to do this, but doesn't quite do the trick:
dpLocation = dataworkbook.Worksheets(cSht).Range("PlotLocation").Row
dpLocation = CLng(dpLocation * 14.25)
Set TSChart = dataworkbook.Worksheets(cSht).ChartObjects.Add(80, dpLocation, 620, 380)
TSChart.Activate
Then other stuff is done to set axis, data range, ... Thanks for your help!!
-Mike
I've got some code that generates a chart and locates it on the worksheet. But some time later when I've added more rows above where the chart is generated, the next time I generate the chart its position overlaps some of my excel calculations.
My thought was to locate the chart relative to a named range; so, that it will always be the same number of rows to that range, even when the worksheet has changed.
Here's the code I've tried to do this, but doesn't quite do the trick:
dpLocation = dataworkbook.Worksheets(cSht).Range("PlotLocation").Row
dpLocation = CLng(dpLocation * 14.25)
Set TSChart = dataworkbook.Worksheets(cSht).ChartObjects.Add(80, dpLocation, 620, 380)
TSChart.Activate
Then other stuff is done to set axis, data range, ... Thanks for your help!!
-Mike