<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Dynamic Chart Source Data</title>
	<atom:link href="http://peltiertech.com/WordPress/dynamic-chart-source-data/feed/" rel="self" type="application/rss+xml" />
	<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/</link>
	<description>PTS Excel Charts and Tutorials Blog</description>
	<lastBuildDate>Sat, 21 Nov 2009 04:01:08 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-21793</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Sat, 07 Nov 2009 15:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-21793</guid>
		<description>Ardalan -

I see. You may have one to 30 series, and you want the existing data sets to automatically be charted. Any data sets which are removed, you want the series also removed. This could ba accomplished through a dedicated VBA procedure.

I assumed one worksheet, ChartData, which had potentially plottable data in A1:P20, and which also had one embedded chart, the one to be upddated. This procedure clears all series from the chart, checks each pair of columns in the data range, and if both columns contain plottable data (e.g., not errors), a series is added using these two columns.

&lt;pre class=&quot;vbasmall&quot;&gt;Sub DynamicChartRange()
  Const sADDRESS As String = &quot;A1:P20&quot;
  Dim rTotal As Range
  Dim cDynamic As Chart
  Dim iSrs As Long
  
  Set rTotal = Worksheets(&quot;ChartData&quot;).Range(sADDRESS)
  Set cDynamic = Worksheets(&quot;ChartData&quot;).ChartObjects(1).Chart
  
  &#039; clear the chart
  Do While cDynamic.SeriesCollection.Count &gt; 0
    cDynamic.Legend.LegendEntries(1).LegendKey.Delete
  Loop
  
  &#039; add series from total range
  For iSrs = 1 To rTotal.Columns.Count / 2
    &#039; check columns for data
    If WorksheetFunction.Count(rTotal.Columns(iSrs * 2 - 1)) &gt; 0 And _
        WorksheetFunction.Count(rTotal.Columns(iSrs * 2)) &gt; 0 Then
      &#039; we have data to plot
      With cDynamic.SeriesCollection.NewSeries
        .Values = rTotal.Columns(iSrs * 2)
        .XValues = rTotal.Columns(iSrs * 2 - 1)
      End With
    End If
  Next
  
End Sub&lt;br /&gt;
&#160;&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>Ardalan -</p>
<p>I see. You may have one to 30 series, and you want the existing data sets to automatically be charted. Any data sets which are removed, you want the series also removed. This could ba accomplished through a dedicated VBA procedure.</p>
<p>I assumed one worksheet, ChartData, which had potentially plottable data in A1:P20, and which also had one embedded chart, the one to be upddated. This procedure clears all series from the chart, checks each pair of columns in the data range, and if both columns contain plottable data (e.g., not errors), a series is added using these two columns.</p>
<pre class="vbasmall">Sub DynamicChartRange()
  Const sADDRESS As String = "A1:P20"
  Dim rTotal As Range
  Dim cDynamic As Chart
  Dim iSrs As Long

  Set rTotal = Worksheets("ChartData").Range(sADDRESS)
  Set cDynamic = Worksheets("ChartData").ChartObjects(1).Chart

  ' clear the chart
  Do While cDynamic.SeriesCollection.Count > 0
    cDynamic.Legend.LegendEntries(1).LegendKey.Delete
  Loop

  ' add series from total range
  For iSrs = 1 To rTotal.Columns.Count / 2
    ' check columns for data
    If WorksheetFunction.Count(rTotal.Columns(iSrs * 2 - 1)) > 0 And _
        WorksheetFunction.Count(rTotal.Columns(iSrs * 2)) > 0 Then
      ' we have data to plot
      With cDynamic.SeriesCollection.NewSeries
        .Values = rTotal.Columns(iSrs * 2)
        .XValues = rTotal.Columns(iSrs * 2 - 1)
      End With
    End If
  Next

End Sub
&nbsp;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ardalan</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-21773</link>
		<dc:creator>Ardalan</dc:creator>
		<pubDate>Sat, 07 Nov 2009 04:50:01 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-21773</guid>
		<description>Jon,
The ranges are like this:
X 1 = A1:A500     Y 1 = B1:B500
X 2 = C1:C500    Y 2 = D1:D500
.
.
X 30 = AD1:AD500    Y 30 = AE1:AE500
These data come from some calculations of other data. I have put a formula if there is no data it replies #N/A for my graph. For each X &amp; Y graph should draw a line. I want this adding happens automatically, ie.; if I have 3 set of XY data , the chart only draw 3 lines &amp; in case I add more to these 3, say 2, Graph should automatically add another 2 series &amp; shows 5 lines and in case I delete one, graph reduces one.</description>
		<content:encoded><![CDATA[<p>Jon,<br />
The ranges are like this:<br />
X 1 = A1:A500     Y 1 = B1:B500<br />
X 2 = C1:C500    Y 2 = D1:D500<br />
.<br />
.<br />
X 30 = AD1:AD500    Y 30 = AE1:AE500<br />
These data come from some calculations of other data. I have put a formula if there is no data it replies #N/A for my graph. For each X &amp; Y graph should draw a line. I want this adding happens automatically, ie.; if I have 3 set of XY data , the chart only draw 3 lines &amp; in case I add more to these 3, say 2, Graph should automatically add another 2 series &amp; shows 5 lines and in case I delete one, graph reduces one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-21750</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Fri, 06 Nov 2009 17:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-21750</guid>
		<description>Ardelan - 

How is the source data changing? Is the range changing size?

You might be able to use the utility in &lt;a href=&quot;http://peltiertech.com/WordPress/how-to-edit-series-formulas/&quot; title=&quot;How to Edit Series Formulas &#124; PTS Blog&quot; rel=&quot;nofollow&quot;&gt;How to Edit Series Formulas&lt;/a&gt; to adjust the last row, especially if all data ends at the same row.</description>
		<content:encoded><![CDATA[<p>Ardelan &#8211; </p>
<p>How is the source data changing? Is the range changing size?</p>
<p>You might be able to use the utility in <a href="http://peltiertech.com/WordPress/how-to-edit-series-formulas/" title="How to Edit Series Formulas | PTS Blog" rel="nofollow">How to Edit Series Formulas</a> to adjust the last row, especially if all data ends at the same row.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ardalan</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-21745</link>
		<dc:creator>Ardalan</dc:creator>
		<pubDate>Fri, 06 Nov 2009 16:02:17 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-21745</guid>
		<description>Hi Jon,
Thanx for your great ideas.
I have a problem with making a X-Y dynamic chart. Actually i have around 30 X &amp; 30 Y values in collumns tight together (X1 Y1, X2 Y2, etc) that can be shown in X-Y graph. What should I do that graph can be updated automatically without using source data/addseries one by one.</description>
		<content:encoded><![CDATA[<p>Hi Jon,<br />
Thanx for your great ideas.<br />
I have a problem with making a X-Y dynamic chart. Actually i have around 30 X &amp; 30 Y values in collumns tight together (X1 Y1, X2 Y2, etc) that can be shown in X-Y graph. What should I do that graph can be updated automatically without using source data/addseries one by one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-6242</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Wed, 19 Nov 2008 10:58:32 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-6242</guid>
		<description>CIBER -

I generally use Forms menu controls for this, but you can use validation just as well. 

When using worksheet formulas, usually OFFSET and INDEX are used to define the position and size of a range. In VBA one uses .Offset and .Resize for the same purpose. Your arguments for these functions have to include references to the cells with the validation or control link values.

For example, referring to the Name defined at the top of this article:

&lt;pre class=&quot;vba&quot;&gt;Name: ChtSourceData
Refers To: =OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B)+1,COUNTA(Sheet1!$2:$2)+1)&lt;/pre&gt;

If cell D1 contains the value that indicates my row offset for the start of the data, I would insert it into this formula:

&lt;pre class=&quot;vba&quot;&gt;Name: ChtSourceData
Refers To: =OFFSET(Sheet1!$B$2,&lt;span style=&quot;color: red;&quot;&gt;Sheet1!$D$1&lt;/span&gt;,0,COUNTA(Sheet1!$B:$B)+1,COUNTA(Sheet1!$2:$2)+1)&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>CIBER -</p>
<p>I generally use Forms menu controls for this, but you can use validation just as well. </p>
<p>When using worksheet formulas, usually OFFSET and INDEX are used to define the position and size of a range. In VBA one uses .Offset and .Resize for the same purpose. Your arguments for these functions have to include references to the cells with the validation or control link values.</p>
<p>For example, referring to the Name defined at the top of this article:</p>
<pre class="vba">Name: ChtSourceData
Refers To: =OFFSET(Sheet1!$B$2,0,0,COUNTA(Sheet1!$B:$B)+1,COUNTA(Sheet1!$2:$2)+1)</pre>
<p>If cell D1 contains the value that indicates my row offset for the start of the data, I would insert it into this formula:</p>
<pre class="vba">Name: ChtSourceData
Refers To: =OFFSET(Sheet1!$B$2,<span style="color: red;">Sheet1!$D$1</span>,0,COUNTA(Sheet1!$B:$B)+1,COUNTA(Sheet1!$2:$2)+1)</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: CIBER</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-6238</link>
		<dc:creator>CIBER</dc:creator>
		<pubDate>Wed, 19 Nov 2008 09:21:51 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-6238</guid>
		<description>I have a senario in which i have to change the source data of the graph by using some validation inputs, 
Eg : i have a set of data in rows which is used to create the graph , now i have to change the source data with refference to the a particular row. 
+ values  to select the rows  after refference  row &amp; -ve for rows before refference row .

say if i give +3 , -5 , then the source data become 5+3+1(reffernce row ) = 9 rows totally shd be used to create the graph 

All this has to be done dyanamically how can it be done.</description>
		<content:encoded><![CDATA[<p>I have a senario in which i have to change the source data of the graph by using some validation inputs,<br />
Eg : i have a set of data in rows which is used to create the graph , now i have to change the source data with refference to the a particular row.<br />
+ values  to select the rows  after refference  row &amp; -ve for rows before refference row .</p>
<p>say if i give +3 , -5 , then the source data become 5+3+1(reffernce row ) = 9 rows totally shd be used to create the graph </p>
<p>All this has to be done dyanamically how can it be done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-4586</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Fri, 03 Oct 2008 20:56:40 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-4586</guid>
		<description>Nick -

In my example, the series names are in the first row of the range &quot;ChtSourceData&quot;. Keep the top left cell blank, put the series names in the rest of the top row of this range, and the X values or category labels in the rest of the first row.</description>
		<content:encoded><![CDATA[<p>Nick -</p>
<p>In my example, the series names are in the first row of the range &#8220;ChtSourceData&#8221;. Keep the top left cell blank, put the series names in the rest of the top row of this range, and the X values or category labels in the rest of the first row.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nick</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-4584</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Fri, 03 Oct 2008 20:48:08 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-4584</guid>
		<description>Jon,

Cam across your website in need of excel guidance.
This is great and I have been playing with this and learning.

However, when I execute the code, it resets the labeling of the series in the chart.
Thinking about it, I could define a name for each series and then add an update into the macro to update the series using the definition but I think there must be a quicker way of doing this especially when there are several series.

Thanks,
Nick</description>
		<content:encoded><![CDATA[<p>Jon,</p>
<p>Cam across your website in need of excel guidance.<br />
This is great and I have been playing with this and learning.</p>
<p>However, when I execute the code, it resets the labeling of the series in the chart.<br />
Thinking about it, I could define a name for each series and then add an update into the macro to update the series using the definition but I think there must be a quicker way of doing this especially when there are several series.</p>
<p>Thanks,<br />
Nick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Peltier</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-4401</link>
		<dc:creator>Jon Peltier</dc:creator>
		<pubDate>Sun, 28 Sep 2008 00:53:56 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-4401</guid>
		<description>Doug -

You need to define a range for each chart, and you should name each chart. To name a chart, hold Shift while selecting the cart, and type a distinctive name in the Name Box. Something like DynoChart1 and DynoChart2. If you have questions about this, see my tutorial &lt;/a&gt;&lt;a href=&quot;http://peltiertech.com/Excel/ChartsHowTo/NameAChart.html&quot; rel=&quot;nofollow&quot;&gt;Chart Names&lt;/a&gt;. Use ranges named DynoRange1 and DynoRange2. Then in the code:

&lt;pre class=&quot;vba&quot;&gt;Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Me.Range(&quot;DynoRange1&quot;)) Is Nothing Then
    Me.ChartObjects(&quot;DynoChart1&quot;).Chart.SetSourceData _
        Source:=Me.Range(&quot;DynoRange1&quot;), _
        PlotBy:=xlColumns
  ElseIf Not Intersect(Target, Me.Range(&quot;DynoRange2&quot;)) Is Nothing Then
    Me.ChartObjects(&quot;DynoChart2&quot;).Chart.SetSourceData _
        Source:=Me.Range(&quot;DynoRange2&quot;), _
        PlotBy:=xlColumns
  End If
End Sub&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Doug -</p>
<p>You need to define a range for each chart, and you should name each chart. To name a chart, hold Shift while selecting the cart, and type a distinctive name in the Name Box. Something like DynoChart1 and DynoChart2. If you have questions about this, see my tutorial <a href="http://peltiertech.com/Excel/ChartsHowTo/NameAChart.html" rel="nofollow">Chart Names</a>. Use ranges named DynoRange1 and DynoRange2. Then in the code:</p>
<pre class="vba">Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Me.Range("DynoRange1")) Is Nothing Then
    Me.ChartObjects("DynoChart1").Chart.SetSourceData _
        Source:=Me.Range("DynoRange1"), _
        PlotBy:=xlColumns
  ElseIf Not Intersect(Target, Me.Range("DynoRange2")) Is Nothing Then
    Me.ChartObjects("DynoChart2").Chart.SetSourceData _
        Source:=Me.Range("DynoRange2"), _
        PlotBy:=xlColumns
  End If
End Sub</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://peltiertech.com/WordPress/dynamic-chart-source-data/comment-page-1/#comment-4394</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Sat, 27 Sep 2008 18:31:04 +0000</pubDate>
		<guid isPermaLink="false">http://peltiertech.com/WordPress/?p=136#comment-4394</guid>
		<description>This is a great tip.  But I need help on one more step.  I am setting up the dynamic update in the worksheet code.  Your code works for 1 chart but I need to update 2 charts on the same page.  How would I modify the VBA code to support 2 different charts on the worksheet?</description>
		<content:encoded><![CDATA[<p>This is a great tip.  But I need help on one more step.  I am setting up the dynamic update in the worksheet code.  Your code works for 1 chart but I need to update 2 charts on the same page.  How would I modify the VBA code to support 2 different charts on the worksheet?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
