Help with Chart VBA

mrhuman

New Member
Joined
Sep 14, 2015
Messages
13
I have a chart with column stacked and line from a table of 60 columns and the 59th column alone is the line which cuts the columns something like the image shown. Problem is I have code like this
Code:
 ActiveChart.SeriesCollection(59).ChartType = xlLine
    ActiveChart.Axes(xlValue).MajorGridlines.Select

But if a column in the table is added or deleted I have to manually enter the column number for the line.
Can someone tell me how to make the chart dynamically understand to choose only the second last column for line chart.


barchartpost.png
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi,

Code:
ActiveChart.SeriesCollection.Count
[/code
Will tell you the total number of series. So:
[code]
ActiveChart.SeriesCollection(ActiveChart.SeriesCollection.Count-1).ChartType = xlLine
would be one way to do it.

I might try to make it easy for myself and always do that one first so it would always be number 1.

Regards,
 
Upvote 0

Forum statistics

Threads
1,214,627
Messages
6,120,610
Members
448,973
Latest member
ChristineC

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