Summing within an array

  • Thread starter Thread starter fcarr
  • Start date Start date
F

fcarr

I am trying to conditionally sum a series of data, all of which is
within one column. The issue is that the data I need summed is mixed
up with various labels. In other words:

Label 1
Data x

Label 2
Data y

Label 1
Data z

I want to automote a calculation which will give me, say, a sum of all
the appropriate data underneath a "Label 1" (so the returned value
would be (data x + data z).

I have enclosed a spreadsheet to be more explicit.

Any help would be great - thanks.


+----------------------------------------------------------------+
| Attachment filename: needhelp.xls |
|Download attachment: http://www.excelforum.com/attachment.php?postid=365999|
+----------------------------------------------------------------+
 
I can only think of a VBA solution:
assuming your data is in column a and you want the answer in cell b1


sub sumlabel1()
mysum=0
for ctr=1 to 64000
if cells(ctr,1).value="label 1" then mysum=mysum+cells(ctr+1,1).value
next
range("b1").value=mysum
End sub
 
Back
Top