<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: ExcelFilter: How do I display the sum within that column without resulting in a "circular reference" error?</title>
	<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error/</link>
	<description>Comments on Ask MetaFilter post ExcelFilter: How do I display the sum within that column without resulting in a "circular reference" error?</description>
	<pubDate>Fri, 29 Jun 2007 22:17:53 -0800</pubDate>
	<lastBuildDate>Fri, 29 Jun 2007 22:17:53 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: ExcelFilter: How do I display the sum within that column without resulting in a &quot;circular reference&quot; error?</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error</link>	
		<description>ExcelFilter: How do I display the sum within that column without resulting in a &quot;circular reference&quot; error? &lt;br /&gt;&lt;br /&gt; I&apos;m building a spreadsheet to keep track of my paychecks.  I&apos;d like to keep track of YTD totals of a column (eg, federal taxes) at the top of &lt;i&gt;that&lt;/i&gt; column, and find a formula that I can enter once into the top that will calculate the sum for the rest of the column for as many entries as I choose to make.  Simply summing the entire column results in a circular reference error.&lt;br&gt;
&lt;br&gt;
In other wods, for the simplified example below, give me a function for [SUM_FEDERAL] (in B1) that will sum the individual values for each cheque without me having to adjust/copy the function for each entry of a new cheque. (I know I could simply do =SUM(B4:B100), and adjust after 100 entries, but I want a solution that both scales and makes it simple to maintain).&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;tr&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;A&lt;/th&gt;&lt;th&gt;B&lt;/th&gt;&lt;/tr&gt;&lt;br&gt;
&lt;tr&gt;&lt;th&gt;1&lt;/th&gt;&lt;td&gt;YTD      &lt;/td&gt;&lt;td&gt;&lt;i&gt;[SUM_FEDERAL]&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;
&lt;tr&gt;&lt;th&gt;2&lt;/th&gt; &lt;/tr&gt;&lt;br&gt;
&lt;tr&gt;&lt;th&gt;3&lt;/th&gt;&lt;td&gt; Cheque No.  &amp;amp;nbsp &amp;amp;nbsp&lt;/td&gt;&lt;td&gt;Federal&lt;/td&gt; &lt;/tr&gt;&lt;br&gt;
&lt;tr&gt;&lt;th&gt;4&lt;/th&gt;&lt;td&gt;01&lt;/td&gt;&lt;td&gt;5&lt;/td&gt; &lt;/tr&gt;&lt;br&gt;
&lt;tr&gt;&lt;th&gt;5&lt;/th&gt;&lt;td&gt;02&lt;/td&gt;&lt;td&gt;8&lt;/td&gt; &lt;/tr&gt;&lt;br&gt;
&lt;tr&gt;&lt;th&gt;6&lt;/th&gt;&lt;td&gt;03&lt;/td&gt;&lt;td&gt;7&lt;/td&gt; &lt;/tr&gt;&lt;br&gt;
&lt;/table&gt;&lt;br&gt;
&lt;br&gt;
I imagine that there is a super simple solution -- after several hours of playing around and searching Google, I&apos;ve given up and turned to MeFi.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2007:site.65955</guid>
		<pubDate>Fri, 29 Jun 2007 22:10:56 -0800</pubDate>
		<dc:creator>chefscotticus</dc:creator>
		
			<category>excel</category>
		
			<category>column</category>
		
			<category>sum</category>
		
			<category>circularreferenceerror</category>
		
	</item> <item>
		<title>By: The Deej</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990750</link>	
		<description>If I am picturing this correctly... and maybe I am not...&lt;br&gt;
&lt;br&gt;
Why not make a sum cell way at the bottom of the column (A500 or whatever) then make A1 (=A500)&lt;br&gt;
&lt;br&gt;
I must be missing something.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990750</guid>
		<pubDate>Fri, 29 Jun 2007 22:17:53 -0800</pubDate>
		<dc:creator>The Deej</dc:creator>
	</item><item>
		<title>By: chefscotticus</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990753</link>	
		<description>(Hmm. Tables don&apos;t work in MeFi apparently.  See the formatted example here: &lt;a href=&quot;http://img39.picoodle.com/img/img39/8/6/30/f_askmefiexcem_0896809.jpg&quot;&gt;http://img39.picoodle.com/img/img39/8/6/30/f_askmefiexcem_0896809.jpg&lt;/a&gt;)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990753</guid>
		<pubDate>Fri, 29 Jun 2007 22:21:06 -0800</pubDate>
		<dc:creator>chefscotticus</dc:creator>
	</item><item>
		<title>By: ormondsacker</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990755</link>	
		<description>You&apos;re concerned about outgrowing whatever limit you set, right?  In Excel 2000, &lt;a href=&quot;http://support.microsoft.com/kb/264626&quot;&gt;you cannot increase the number of worksheet rows beyond 65,536. &lt;/a&gt;  So you&apos;ll never outpace SUM (B2:B65536).</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990755</guid>
		<pubDate>Fri, 29 Jun 2007 22:23:26 -0800</pubDate>
		<dc:creator>ormondsacker</dc:creator>
	</item><item>
		<title>By: demiurge</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990756</link>	
		<description>I don&apos;t use Excel, but I think a better formulation of this question is that you want a function that does:&lt;br&gt;
&lt;br&gt;
Sum the cells in a column starting from a fixed address &lt;i&gt;n&lt;/i&gt; to the last non-blank cell in that column.&lt;br&gt;
&lt;br&gt;
Although you are probably over-thinking the whole thing and I recommend ormondsacker&apos;s fix.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990756</guid>
		<pubDate>Fri, 29 Jun 2007 22:26:45 -0800</pubDate>
		<dc:creator>demiurge</dc:creator>
	</item><item>
		<title>By: b1tr0t</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990758</link>	
		<description>For column B:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;=sum(b:b-b1)&lt;/pre&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990758</guid>
		<pubDate>Fri, 29 Jun 2007 22:28:15 -0800</pubDate>
		<dc:creator>b1tr0t</dc:creator>
	</item><item>
		<title>By: b1tr0t</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990759</link>	
		<description>(put that formula in cell b1, obviously)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990759</guid>
		<pubDate>Fri, 29 Jun 2007 22:28:44 -0800</pubDate>
		<dc:creator>b1tr0t</dc:creator>
	</item><item>
		<title>By: chefscotticus</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990770</link>	
		<description>@ b1tr0t: sorry mate, doesn&apos;t seem work.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990770</guid>
		<pubDate>Fri, 29 Jun 2007 22:46:00 -0800</pubDate>
		<dc:creator>chefscotticus</dc:creator>
	</item><item>
		<title>By: ormondsacker</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990795</link>	
		<description>&lt;small&gt;&lt;i&gt;Did you mean to best-answer yourself?&lt;/i&gt;&lt;/small&gt;&lt;br&gt;
&lt;br&gt;
I don&apos;t have Excel loaded on this computer to test, but if you&apos;re looking for more elegance, I think this should work as a generalized solution:&lt;br&gt;
&lt;br&gt;
=SUMIF(A:A, &lt;&gt;$A$1, B:B)&lt;br&gt;
&lt;br&gt;
Basically, that looks at each row in turn to see if the A value is the same as the cell in A1 - if it&apos;s different, it adds that B value to the overall total.  The way your spreadsheet is set up, that should add all B values except the one in row 1, preventing a circular reference.  I &lt;em&gt;think&lt;/em&gt; Excel is smart enough to pull that off, but check it first.&lt;/&gt;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990795</guid>
		<pubDate>Fri, 29 Jun 2007 23:33:55 -0800</pubDate>
		<dc:creator>ormondsacker</dc:creator>
	</item><item>
		<title>By: alexei</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990798</link>	
		<description>If you insert a new line among the lines being summed, then the sum will automatically be adjusted to include the new entry as well as all the previous entries. This works best when the sum is at the end, forcing you to insert new lines to add more data.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990798</guid>
		<pubDate>Fri, 29 Jun 2007 23:35:49 -0800</pubDate>
		<dc:creator>alexei</dc:creator>
	</item><item>
		<title>By: yclipse</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#990882</link>	
		<description>By the way, you should get in the habit of putting the sum cell &lt;strong&gt;at the top&lt;/strong&gt; of the column of numbers being added, rather than at the bottom. The sum is very often the bit of information that the user first wants to see, and it should display as soon as she navigates to that sheet.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-990882</guid>
		<pubDate>Sat, 30 Jun 2007 05:04:06 -0800</pubDate>
		<dc:creator>yclipse</dc:creator>
	</item><item>
		<title>By: NailsTheCat</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#991137</link>	
		<description>I think you&apos;re being a little too much of a purist here. It is possible however -- you need to use a UDF &lt;br&gt;
&lt;br&gt;
(User Defined Function). Here&apos;s a couple of ways of doing it.&lt;br&gt;
&lt;br&gt;
(1) Only works for single column, non contiguous range -- but it&apos;s fast.&lt;br&gt;
&lt;br&gt;
Place the following formula in your cell B1:&lt;br&gt;
&lt;br&gt;
=SUMRANGEWITHEXCEPTION1(B:B,B1:B4)&lt;br&gt;
&lt;br&gt;
And insert a macro module into your workbook and place the following code in there:&lt;br&gt;
&lt;br&gt;
Public Function SUMRANGEWITHEXCEPTION1(rng1 As Range, rng2 As Range) As Double&lt;br&gt;
&lt;br&gt;
Dim rngToSum As Range&lt;br&gt;
Dim lCountExclusions As Long&lt;br&gt;
Dim lRow As Long&lt;br&gt;
&lt;br&gt;
    &apos; Must be single column and non-contiguous range&lt;br&gt;
    &lt;br&gt;
    &apos; get a new range that excludes rng2 from rng 1&lt;br&gt;
    &apos; we&apos;ll use lcount to tell when we&apos;ve finished the exclusion&lt;br&gt;
    &apos; and can therefore stop -- to speed it up&lt;br&gt;
    With rng1&lt;br&gt;
        For lRow = 1 To .Rows.Count&lt;br&gt;
            If lCountExclusions = rng2.Cells.Count Then Exit For&lt;br&gt;
            If Intersect(.Cells(lRow, 1), rng2) Is Nothing Then&lt;br&gt;
                If rngToSum Is Nothing Then&lt;br&gt;
                    Set rngToSum = Range(.Cells(lRow, 1))&lt;br&gt;
                Else&lt;br&gt;
                    Set rngToSum = Union(rngToSum, .Cells(lRow, 1))&lt;br&gt;
                End If&lt;br&gt;
            Else&lt;br&gt;
                lCountExclusions = lCountExclusions + 1&lt;br&gt;
            End If&lt;br&gt;
        Next lRow&lt;br&gt;
    &lt;br&gt;
        &apos;On Error Resume Next&lt;br&gt;
        If rngToSum Is Nothing Then&lt;br&gt;
            Set rngToSum = Range(.Cells(lRow, 1), .Cells(.Rows.Count, 1))&lt;br&gt;
        Else&lt;br&gt;
            Set rngToSum = Union(rngToSum, Range(.Cells(lRow, 1), .Cells(.Rows.Count, 1)))&lt;br&gt;
        End If&lt;br&gt;
        On Error GoTo 0&lt;br&gt;
    &lt;br&gt;
    End With&lt;br&gt;
&lt;br&gt;
    SUMRANGEWITHEXCEPTION1 = WorksheetFunction.Sum(rngToSum)&lt;br&gt;
&lt;br&gt;
    Set rngToSum = Nothing&lt;br&gt;
&lt;br&gt;
End Function&lt;br&gt;
&lt;br&gt;
(b) A more universal solution (but slower):&lt;br&gt;
&lt;br&gt;
use :&lt;br&gt;
=SUMRANGEWITHEXCEPTION2(B:B,B1:B4)&lt;br&gt;
&lt;br&gt;
and the following code:&lt;br&gt;
&lt;br&gt;
Public Function SUMRANGEWITHEXCEPTION2(rng1 As Range, rng2 As Range) As Double&lt;br&gt;
Dim c As Range&lt;br&gt;
Dim rngToSum As Range&lt;br&gt;
Dim rngNonBlanks&lt;br&gt;
&lt;br&gt;
 &apos; This supports multiple columns and non-contiguous ranges&lt;br&gt;
&lt;br&gt;
    &apos; get a new range that excludes rng2 from rng 1&lt;br&gt;
    For Each c In rng1.Cells&lt;br&gt;
    &lt;br&gt;
        If Intersect(c, rng2) Is Nothing Then&lt;br&gt;
            If rngToSum Is Nothing Then&lt;br&gt;
                Set rngToSum = c&lt;br&gt;
            Else&lt;br&gt;
                Set rngToSum = Union(rngToSum, c)&lt;br&gt;
            End If&lt;br&gt;
        End If&lt;br&gt;
    Next c&lt;br&gt;
&lt;br&gt;
    SUMRANGEWITHEXCEPTION2 = WorksheetFunction.Sum(rngToSum)&lt;br&gt;
    Set c = Nothing&lt;br&gt;
    Set rngToSum = Nothing&lt;br&gt;
&lt;br&gt;
End Function&lt;br&gt;
&lt;br&gt;
All they do is sum column B as the normal sum function does. But they exclude from the sum the range passed &lt;br&gt;
&lt;br&gt;
as the second argument thereby sidestepping the circular range issue. I think I have a neater solution -- but I have to go dig up weeds. :(</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-991137</guid>
		<pubDate>Sat, 30 Jun 2007 13:54:35 -0800</pubDate>
		<dc:creator>NailsTheCat</dc:creator>
	</item><item>
		<title>By: NailsTheCat</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#991160</link>	
		<description>Errr... I meant of course that function 1 only works for single column &lt;u&gt;contiguous&lt;/u&gt; range. Function 2 works for non-contiguous.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-991160</guid>
		<pubDate>Sat, 30 Jun 2007 15:03:07 -0800</pubDate>
		<dc:creator>NailsTheCat</dc:creator>
	</item><item>
		<title>By: NortonDC</title>
		<link>http://ask.metafilter.com/65955/ExcelFilter-How-do-I-display-the-sum-within-that-column-without-resulting-in-a-circular-reference-error#991767</link>	
		<description>=SUM(B4:B65536)&lt;br&gt;
&lt;br&gt;
I do this, and it works.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2007:site.65955-991767</guid>
		<pubDate>Sun, 01 Jul 2007 14:54:35 -0800</pubDate>
		<dc:creator>NortonDC</dc:creator>
	</item>
	</channel>
</rss>
