ActiveChart.SeriesCollection issue

albclim

New Member
Joined
Sep 11, 2010
Messages
4
Hola

I have been searching the forum looking for an issue that has been poking me this week.
I´ll give a brief description. I have a macro that load, decorate and create pivot tables from a report. Depends of the needs, my boss needs to create a set of reports (from the main one) that automatically will create pivot tables and the grafics. So far I got all working but there is a twist in the you-can-do-better. I have a sheet where different tables can be created by choosing the fields, and there you can choose the type of graph. The twist is to use two types of graphs in the same chart.
I have tried this but wont work

Code:
Sub graficcore()
tablacore
tabladest = Cells(1, 1).Address
With ActiveSheet.UsedRange
    LastRow = .Rows(.Rows.Count).Row
    LastColumn = .Columns(.Columns.Count).Column
End With
tabladest = Cells(1, 1).Address
ultimacelda = Cells(LastRow, LastColumn).Address
down1 = 330            'LastRow * 15 + 30
right1 = 60      'LastColumn * 60 + 120
If LastRow > 20 And LastColumn > 10 Or LastRow > 20 And LastColumn < 10 Then down = LastRow * 15 + 30
With Worksheets(boook(t)).Shapes.AddChart(Left:=(right1), Top:=(down1), Width:=540, Height:=360).Select
ActiveChart.ChartObjects().Activate         <--------ISSUE
    If ga(t) = "" Then ActiveChart.SeriesCollection(1).ChartType = xlColumnField
    If ga(t) = "Column" Then
    ActiveChart.SeriesCollection(1).Select
    ActiveChart.SeriesCollection(1).ChartType = xlColumnField
    End If
    If ga(t) = "Line" Then ActiveChart.SeriesCollection(1).ChartType = xlLineMarkers
    If ga(t) = "Pie" Then ActiveChart.SeriesCollection(1).ChartType = xlPie
    If ga(t) = "Bar" Then ActiveChart.SeriesCollection(1).ChartType = xlBarStacked
    If ga(t) = "Ring" Then ActiveChart.SeriesCollection(1).ChartType = xlBarOfPie
    If ga2(t) = "Colum" Then ActiveChart.SeriesCollection(2).ChartType = "xlColumnField"
    If ga2(t) = "Line" Then
    ActiveChart.SeriesCollection(2).Select
    ActiveChart.SeriesCollection(2).ChartType = xlLineMarkers
    End If
    If ga(t) = "Ring" Or ga(t) = "Pie" Then gaf2 = ""
ActiveChart.ChartStyle = 1
ActiveChart.ApplyLayout (2)
ActiveWorkbook.ShowPivotChartActiveFields = False
ActiveWorkbook.ShowPivotTableFieldList = False
ActiveChart.Refresh
End With
End Sub


The issue comes in the marked line, I dont know how I can choose, one or the other serie to change the graph type.
Any help will be appreciated.
Many thanks
Alb
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I realize this is an old post. But if you add . chart to the flagged line it should work.

ChartObjects().Chart.Activate
 
Upvote 0

Forum statistics

Threads
1,215,242
Messages
6,123,827
Members
449,127
Latest member
Cyko

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