there is a function called sumif() that will conditaionally sum a cell in a column if the value in another column meets a condition.
In this example A1 if the value to test for. Column B is what is conditionally summed, and column C is what is compared to A1
A4=SUMIF(C, A1, B)
column C contains the test values
A1 contains the condition
column B contains the sum values when the valus in the same row matches the value in A1
There is a function reference builting that is pretty helpful. You can open this vy selecting the menu item "View > Show Function Browser"