Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Chart Location

Status
Not open for further replies.

mavest

Programmer
Feb 27, 2003
54
US
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
 
Hi,

Format/Format Chart Area - Properties Tab...

You can select one of three options for positioning.

Other than that, if you use code, use the Top and Left properties of the RANGE to assign to the ChartObject Top & Left properties



Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top