Moving series name on chart to maximum value on chart(VBA)

robertpaulson12345

New Member
Joined
Jun 30, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm fairly new to VBA and I'm trying to format a chart with multiple columns of data automatically. How could I go about positioning specifically the series name of the data to the maximum data for each series of the chart? I've been trying ActiveChart.FullSeriesCollection(counter).DataLabels.Position = findMax but that's not working. I know ActiveChart.FullSeriesCollection(counter).DataLabels.ShowSeriesName shows the name, but I want to manipulate it.
Thanks!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Welcome!

Look at the Series Object of the chart, specifically the Name property. The base code might look something like
VBA Code:
ThisWorkbook.Worksheets("SheetName").ChartObjects(1).Chart.SeriesCollection(1).Name = "new name"
, substituting in the correct numbers for the chart object and the series number. Or, if you wanted to use ActiveChart (be careful), you would only need
VBA Code:
ActiveChart.SeriesCollection(1).Name = "new name2"
 
Upvote 0
Welcome!

Look at the Series Object of the chart, specifically the Name property. The base code might look something like
VBA Code:
ThisWorkbook.Worksheets("SheetName").ChartObjects(1).Chart.SeriesCollection(1).Name = "new name"
, substituting in the correct numbers for the chart object and the series number. Or, if you wanted to use ActiveChart (be careful), you would only need
VBA Code:
ActiveChart.SeriesCollection(1).Name = "new name2"
Can I move where the series name is displayed on the chart though(up/down X and Y)? It isn't displaying where I want it to.
 
Upvote 0
So you're looking to reposition the legend? If you want exact point control over location, use
VBA Code:
Chart.Legend.Left = xxxx
and
VBA Code:
Chart.Legend.Top = yyyy

Otherwise if you want to just use one of the default positions, you can use Legend.Position.
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,937
Members
449,196
Latest member
Maxkapoor

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