If cell contains a certain text, add the numbers of another cell

Solved/Closed
mmbitar Posts 1 Registration date Saturday February 4, 2017 Status Member Last seen February 5, 2017 - Feb 5, 2017 at 11:36 AM
Mazzaropi Posts 1985 Registration date Monday August 16, 2010 Status Contributor Last seen May 24, 2023 - Feb 6, 2017 at 06:52 AM
Hello, I am trying to do my finances in an easier way, and would appreciate it if anyone can help me with the below question:

B2=Supermarket , C2=30$
B3=Fuel, C3=20$
B4=Fuel, C4=50$

if Bs="Fuel", i want to add the numbers in the adjacents cells together. but only if they contain the text in the B cells.
how can that be done without having to name each cell in case the list is long:
=IF(H6="Fuel", I6, 0)+IF(H7="Fuel", I7, 0)+IF(H8="Fuel", I8, 0)+IF(H9="Fuel", I9, 0)+IF(H10="Fuel", I10, 0)+IF(H11="Fuel", I11, 0) ...

Thank you all in advance!
Related:

1 response

Mazzaropi Posts 1985 Registration date Monday August 16, 2010 Status Contributor Last seen May 24, 2023 147
Feb 6, 2017 at 06:52 AM
mmbitar, Good morning.

Try to use:

=SUMIF(H6:H20, "Fuel", I6:I20)

Adapt range references to your reality.

Is that what you want?
I hope it helps.
--
Belo Horizonte, Brasil.
Marcílio Lobão
0