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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

severynm

Board Regular
Joined
Jan 8, 2021
Messages
220
Office Version
  1. 365
Platform
  1. Windows
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"
 

robertpaulson12345

New Member
Joined
Jun 30, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
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.
 

severynm

Board Regular
Joined
Jan 8, 2021
Messages
220
Office Version
  1. 365
Platform
  1. Windows
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.
 

Forum statistics

Threads
1,144,684
Messages
5,725,760
Members
422,639
Latest member
i have a question

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
Top