Column Clustered chart driving me crazy! (Plotby: xlRows)

Qete_ARG

Board Regular
Joined
Oct 20, 2005
Messages
72
Hello everyone...I am trying to fix this since yesterday but I am running out of time, so I hope someone can help me.
I am creating a Chart from VBA, adding series as needed. The series are not in a continous range, but in separate ranges (all of them are "n" rows by 1 column).
In the line bolded in the code below I get an error. But if I comment out that line and after the chart is created I manually change the design of the chart (change between rows and columns) I can do it. I recorded a macro with this step and that is what tryed to apply, but with no luck.
Can anyone give me some advice?
Really appreciated for your time!
Miguel.

Rich (BB code):
Set myChtObj = ActiveSheet.ChartObjects.Add _
(Left:=250, Width:=375, Top:=75, Height:=225)
With myChtObj.Chart

 .ChartType = xlColumnClustered

 Do Until .SeriesCollection.Count = 0
  .SeriesCollection(1).Delete
 Loop

For i = 0 To ListBox1.ListCount
 For j = 0 To UBound(arrClientesSeleccionados)
  If Sheets("Comparativos").Range("InicioReporte").Offset(0, i).Value = arrClientesSeleccionados(j) Then
   
   With .SeriesCollection.NewSeries
    .Values = Range(Sheets("Comparativos").Range("InicioReporte").Offset(0, i), Sheets("Comparativos").Range("InicioReporte").Offset(0, i).End(xlDown))
    .XValues = Range(Sheets("Comparativos").Range("InicioFechasDelReporte").Offset(0, 0), Sheets("Comparativos").Range("InicioFechasDelReporte").Offset(0, 0).End(xlDown).End(xlDown))
    .Name = Sheets("Comparativos").Range("InicioReporte").Offset(0, i).Value
   End With
    
  End If
 Next j
Next i
.PlotBy = xlRows  <--Here is where I get an error (Error in method 'PlotBy' of the '_Chart' object

End With
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Is there a reason you are doing it this way rather than creating the series as you actually want them? It seems odd to me to create those series in a loop and then try and change them (which is effectively what you are doing).
 
Upvote 0
I really didn´t know how to do it, so I recreated in vba the steps I fllowed when I did it manually.
The only automation in the code was to add the series as I needed them (each serie represents a client, and each client is selected in a multiselect listbox).
If I plot by columns, I have years in the X Axis and the chart shows each client's consumption grouped by year.
If I plot by rows, I have clients in the X axis ans te chart shows each year's consumption but gouped by client. This is what I need. That´s why I try to plot by rows.
If I do it manually I dont have problems, but via code I get that odd error message.
Thanks for your reply rorya!!!
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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