## [Solved] Sum if adjacent contains...

### [Solved] Sum if adjacent contains...

Hi
I'd like to know if it's possible to sum a number (cost) if the adjacent cell contains a specific word.
Example:
On one tab I'd like to make a list of costs, like this:

Cost Item Category
10 Banana Fruit
23 Carrot Vegetable
5 Apple Fruit

One the next tab, I'd like to automatically search the list and sum the costs, in order to see how much I've currently spent on fruit, for example. So that I end up with a new list:

Category Total spent
Fruit 15
Vegetable 23

How do I do it?
Thanks
Last edited by illern on Tue Feb 19, 2019 5:49 pm, edited 1 time in total.
Open Office 4 running on Mac OS Sierra 10
illern

Posts: 11
Joined: Wed Jul 12, 2017 4:57 pm

### Re: Sum if adjacent contains...

SUMIF() will do the job with a formula like
Code: Select all   Expand viewCollapse view
`=SUMIF(Sheet1.C2:C4;A2;Sheet1.A2:A4)`

Please see the attached document. To formula is on Sheet2.
Attachments
SummingFood.ods
Windows 10 and Linux Mint, since 2017
FJCC
Moderator

Posts: 7133
Joined: Sat Nov 08, 2008 8:08 pm

### Re: Sum if adjacent contains...

I love this forum!
Tremendous. Thank you!
Open Office 4 running on Mac OS Sierra 10
illern

Posts: 11
Joined: Wed Jul 12, 2017 4:57 pm

### Re: [Solved] Sum if adjacent contains...

Another approach would be a Pivot Table formerly known as Data Pilot.
Cheers
David
Apache OpenOffice Developer Build 4.2.0 9820 - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine

robleyd
Moderator

Posts: 2643
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia