Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's some code from Excel 2010 that may work. It has a couple specifics (like filtering bad-encode characters from titles) but it was designed to create multiple multi-series graphs from 4-dimensional data having both absolute and percentage-based data. Modify it how you like:</p> <pre><code>Sub createAllGraphs() Const chartWidth As Integer = 260 Const chartHeight As Integer = 200 If Sheets.Count = 1 Then Sheets.Add , Sheets(1) Sheets(2).Name = "AllCharts" ElseIf Sheets("AllCharts").ChartObjects.Count &gt; 0 Then Sheets("AllCharts").ChartObjects.Delete End If Dim c As Variant Dim c2 As Variant Dim cs As Object Set cs = Sheets("AllCharts") Dim s As Object Set s = Sheets(1) Dim i As Integer Dim chartX As Integer Dim chartY As Integer Dim r As Integer r = 2 Dim curA As String curA = s.Range("A" &amp; r) Dim curB As String Dim curC As String Dim startR As Integer startR = 2 Dim lastTime As Boolean lastTime = False Do While s.Range("A" &amp; r) &lt;&gt; "" If curC &lt;&gt; s.Range("C" &amp; r) Then If r &lt;&gt; 2 Then seriesAdd: c.SeriesCollection.Add s.Range("D" &amp; startR &amp; ":E" &amp; (r - 1)), , False, True c.SeriesCollection(c.SeriesCollection.Count).Name = Replace(s.Range("C" &amp; startR), "Â", "") c.SeriesCollection(c.SeriesCollection.Count).XValues = "='" &amp; s.Name &amp; "'!$D$" &amp; startR &amp; ":$D$" &amp; (r - 1) c.SeriesCollection(c.SeriesCollection.Count).Values = "='" &amp; s.Name &amp; "'!$E$" &amp; startR &amp; ":$E$" &amp; (r - 1) c.SeriesCollection(c.SeriesCollection.Count).HasErrorBars = True c.SeriesCollection(c.SeriesCollection.Count).ErrorBars.Select c.SeriesCollection(c.SeriesCollection.Count).ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlCustom, Amount:="='" &amp; s.Name &amp; "'!$F$" &amp; startR &amp; ":$F$" &amp; (r - 1), minusvalues:="='" &amp; s.Name &amp; "'!$F$" &amp; startR &amp; ":$F$" &amp; (r - 1) c.SeriesCollection(c.SeriesCollection.Count).ErrorBar Direction:=xlX, Include:=xlBoth, Type:=xlFixedValue, Amount:=0 c2.SeriesCollection.Add s.Range("D" &amp; startR &amp; ":D" &amp; (r - 1) &amp; ",G" &amp; startR &amp; ":G" &amp; (r - 1)), , False, True c2.SeriesCollection(c2.SeriesCollection.Count).Name = Replace(s.Range("C" &amp; startR), "Â", "") c2.SeriesCollection(c2.SeriesCollection.Count).XValues = "='" &amp; s.Name &amp; "'!$D$" &amp; startR &amp; ":$D$" &amp; (r - 1) c2.SeriesCollection(c2.SeriesCollection.Count).Values = "='" &amp; s.Name &amp; "'!$G$" &amp; startR &amp; ":$G$" &amp; (r - 1) c2.SeriesCollection(c2.SeriesCollection.Count).HasErrorBars = True c2.SeriesCollection(c2.SeriesCollection.Count).ErrorBars.Select c2.SeriesCollection(c2.SeriesCollection.Count).ErrorBar Direction:=xlY, Include:=xlBoth, Type:=xlCustom, Amount:="='" &amp; s.Name &amp; "'!$H$" &amp; startR &amp; ":$H$" &amp; (r - 1), minusvalues:="='" &amp; s.Name &amp; "'!$H$" &amp; startR &amp; ":$H$" &amp; (r - 1) c2.SeriesCollection(c2.SeriesCollection.Count).ErrorBar Direction:=xlX, Include:=xlBoth, Type:=xlFixedValue, Amount:=0 If lastTime = True Then GoTo postLoop End If If curB &lt;&gt; s.Range("B" &amp; r).Value Then If curA &lt;&gt; s.Range("A" &amp; r).Value Then chartX = chartX + chartWidth * 2 chartY = 0 curA = s.Range("A" &amp; r) End If Set c = cs.ChartObjects.Add(chartX, chartY, chartWidth, chartHeight) Set c = c.Chart c.ChartWizard , xlXYScatterSmooth, , , , , True, Replace(s.Range("B" &amp; r), "Â", "") &amp; " " &amp; s.Range("A" &amp; r), s.Range("D1"), s.Range("E1") Set c2 = cs.ChartObjects.Add(chartX + chartWidth, chartY, chartWidth, chartHeight) Set c2 = c2.Chart c2.ChartWizard , xlXYScatterSmooth, , , , , True, Replace(s.Range("B" &amp; r), "Â", "") &amp; " " &amp; s.Range("A" &amp; r) &amp; " (%)", s.Range("D1"), s.Range("G1") chartY = chartY + chartHeight curB = s.Range("B" &amp; r) curC = s.Range("C" &amp; r) End If curC = s.Range("C" &amp; r) startR = r End If If s.Range("A" &amp; r) &lt;&gt; "" Then oneMoreTime = False ' end the loop for real this time r = r + 1 Loop lastTime = True GoTo seriesAdd postLoop: cs.Activate End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload