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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change the position of a legend in a chart using VBA?

Status
Not open for further replies.

feipezi

IS-IT--Management
Aug 10, 2006
316
US
Hi,

Hopefully the subject is clear enough. Yes, that's what I need. The chart that I have has 5 Series in the order of the way chart data presents. But I want Series 1 to be Series 5. I know I can do it by Chart Data, Up and Down arrows to change the position. But the chart is a dynamic one, i.e., every time I press a button, the chart will be updated by a new set of data. The position of legend will go back to where it was.

The way of doing it is to set up a macro. I recorded a macro to see the code of moving U and D arrow but the code won't show.

Thanks in advance.

 
Somebody will come up with something neater but

Sheets("Chart1").Activate
ActiveChart.Legend.Top = 100
ActiveChart.Legend.Left = 100

should get you started
 




Your questions nad statements are contradictory.

Do you want to change the POSITION the legend box or do you want to change the sequence of the series WITHIN the legend box?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
What Skip said.

Also, what version of Office are you running?

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Hi,

I'm running 2007 Office. I don't think there is a big diff. between 2003 and 07 for that matter.

Of course I want to change position of series INSIDE the legend box. The position of the legend box can be easily changed by Layout dropdown. No need for VBA to set in.

I believe ajrimmer was talking about the position of the legend box too. That's not what I want. In my question, I said I want Series1 to be Series5, which has nothing to do with the placement of the legend box.

Thanks all for your endeavor.
 



Assign SeriesCollection(1).Plotorder = 5 in the Chart Object.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

Thanks alot for the tip. It works.

Thanks to ajrimmer and other folks too for your involvement.

Take care.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top