Series formula too long error in VBA charts

adventurer

New Member
Joined
Jul 1, 2015
Messages
9
Hi,

I have the following data with 23 departments.
The row one department cells are merged.


0

I am trying to make two charts using VBA; one for Actual and one For % of total by the following code. I am getting two graphs until in the For loop of i Column the values do not exceed 35 and 36 respectively in place of 29 and 30 respectively. As I exceed the values 35 and 36 resp, it shows 'Series Formula Too Long' error and the grphs are not plotted. Please tell me why this is happening and what is the solution for the same.
Thanks.




Sub TwoCharts11()


Dim rChart1 As Range
Dim rChart2 As Range
Dim iColumn As Long


Dim cht1 As Chart
Dim cht2 As Chart


Const StrtRow As Long = 2
Const EndRow As Long = 6


With ActiveSheet


Set rChart1 = .Range(.Cells(StrtRow, "B"), .Cells(EndRow, "B"))
Set rChart2 = .Range(.Cells(StrtRow, "B"), .Cells(EndRow, "B"))


For iColumn = 3 To 29 Step 2
Set rChart1 = Union(rChart1, .Range(.Cells(StrtRow, iColumn), .Cells(EndRow, iColumn)))
Next


For iColumn = 4 To 30 Step 2
Set rChart2 = Union(rChart2, .Range(.Cells(StrtRow, iColumn), .Cells(EndRow, iColumn)))
Next


Set cht1 = .Shapes.AddChart.Chart
Set cht2 = .Shapes.AddChart.Chart

With cht1
.Parent.Left = .Parent.Left - .Parent.Width / 2
.ChartType = xlColumnClustered
.SetSourceData rChart1
End With

With cht2
.Parent.Left = .Parent.Left + .Parent.Width / 2
.ChartType = xlColumnClustered
.SetSourceData rChart2
End With

End With




End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi,

The images are not visible to others. So kindly give your email addresses so that I can mail the image to you. Or you can also find the similar data set at
MrExcel-TwoChartsPartDeux.png


for example my data set has 23 pcts and 23 acts as above.
 
Upvote 0
Last edited:
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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