sum all items in list based on condition

Padthelad

Board Regular
Joined
May 13, 2016
Messages
54
Hi,

I have the following list of data:-

Code:
[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]750<style type="text/css">p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: right; font: 10.0px Verdana}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 10.0px Verdana}table.t1 {border-collapse: collapse}td.td1 {border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #cbcbcb #cbcbcb #cbcbcb #cbcbcb; padding: 0.0px 5.0px 0.0px 5.0px}</style>[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]g unsalted butter[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]4[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]lemons[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]6[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]cloves garlic[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]2[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]packs parsley[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]2[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]clementine[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]2[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]red chilli[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD]2[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]packs rosemary[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]14[/TD]
[TD]2[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]packs sage[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]15[/TD]
[TD]24[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]bay leaves[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]16[/TD]
[TD]500[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]g unsalted butter[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]17[/TD]
[TD]1[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]whole nutmeg[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]18[/TD]
[TD]24[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]smoked streaky[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]19[/TD]
[TD]4[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]onions[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]20[/TD]
[TD]4[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]carrots[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]21[/TD]
[TD]4[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]celery[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]22[/TD]
[TD]1[/TD]
[TD]<style><!--table	{mso-displayed-decimal-separator:"\.";	mso-displayed-thousand-separator:"\,";}.font5	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;}td	{padding-top:1px;	padding-right:1px;	padding-left:1px;	mso-ignore:padding;	color:windowtext;	font-size:10.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-number-format:General;	text-align:general;	vertical-align:bottom;	border:none;	mso-background-source:auto;	mso-pattern:auto;	mso-protection:locked visible;	white-space:nowrap;	mso-rotate:0;}ruby	{ruby-align:left;}rt	{color:windowtext;	font-size:8.0pt;	font-weight:400;	font-style:normal;	text-decoration:none;	font-family:Verdana;	mso-generic-font-family:auto;	mso-font-charset:0;	mso-char-type:none;	display:none;}--></style>[TABLE="width: 196"]
 <colgroup><col width="196"> </colgroup><tbody>[TR]
<!--StartFragment-->  [TD="width: 196"]bulb garlic[/TD]
<!--EndFragment--> [/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD]23[/TD]
[TD]6[/TD]
[TD]cloves garlic
[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I would like a formula to search the column A and B and total the amount in column A next to, for example, g unsalted butter (1250). or 'cloves of garlic (12)

The current DSUM i'm using only returns the total of column A, =DSUM(A7:B22,1,B7:B22) returns 582

The current Index Match i'm using only returns the item in the column, A7:B22,MATCH("lemons",B7:B22,0),2,1) returns lemons.

Any help anyone can provide is very much appreciated.

Thanks,

Pad
 

Marcelo Branco

MrExcel MVP
Joined
Aug 23, 2010
Messages
16,317
Try SUMIF - something like this


D
E
1
Criteria​
Result​
2
g unsalted butter​
1250​
3
cloves garlic​
12​

<tbody>
</tbody>


Criteria in column D
Formula in E2 copied down
=SUMIF(B:B,D2,A:A)

Hope this helps

M.
 
Last edited:

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,666
SUMIF is the simplest way (see Marcelo's post #2). If you want to stick with database functions you can define criteria. In the example below, I have named the range A6:B23 "Database" and the range E3:F4 "CR_g" (the criteria range for g unsalted butter). You can change the criteria for Item in F4 to get sums for the other items.
Excel Workbook
ABCDEF
2****CR_g*
3****QtyItem
4*****g unsalted butter
5******
6QtyItem**
7750g unsalted butter****
84lemons****
96cloves garlic****
102packs parsley****
112clementine****
122red chilli****
132packs rosemary****
142packs sage****
1524bay leaves****
16500g unsalted butter****
171whole nutmeg****
1824smoked streaky****
194onions****
204carrots****
214celery****
221bulb garlic****
236cloves garlic****
Sheet8
 

Padthelad

Board Regular
Joined
May 13, 2016
Messages
54
Thank you for your formula, works a treat.

Is there a way you now of to eliminate the repeats quickly?

The formula copied down no gives the following

<style><!--table {mso-displayed-decimal-separator:"\."; mso-displayed-thousand-separator:"\,";}td {padding-top:1px; padding-right:1px; padding-left:1px; mso-ignore:padding; color:windowtext; font-size:10.0pt; font-weight:400; font-style:normal; text-decoration:none; font-family:Verdana; mso-generic-font-family:auto; mso-font-charset:0; mso-number-format:General; text-align:general; vertical-align:bottom; border:none; mso-background-source:auto; mso-pattern:auto; mso-protection:locked visible; white-space:nowrap; mso-rotate:0;}ruby {ruby-align:left;}rt {color:windowtext; font-size:8.0pt; font-weight:400; font-style:normal; text-decoration:none; font-family:Verdana; mso-generic-font-family:auto; mso-font-charset:0; mso-char-type:none; display:none;}--></style>
1250g unsalted butter
4lemons
6cloves garlic
2packs flat leaf parsley
2clementine
2red chilli
2packs rosemary
2packs sage
24bay leaves
1250g unsalted butter
1whole nutmeg
24smoked streaky
4onions
4carrots
4celery
1bulb garlic

<!--StartFragment--> <colgroup><col width="159" span="2"> </colgroup><tbody>
<!--EndFragment--></tbody>
Is it now possible to search the two columns and delete the copy instances of 'g unsalted butter'? My data set is much larger than this one recipe.

Thank you for any help you can provide.

Pad
 

Forum statistics

Threads
1,082,323
Messages
5,364,583
Members
400,809
Latest member
formulasataglance

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top