## Sum values in a range where adjacent cell value equals a criterion in excel

**Question:** How do I sum all values in a range where adjacent cell value equals a criterion?

The criterion is in cell **B19** (Pen).

Array formula in C19:

**B19**, C4:G14, 0)) + CTRL + SHIFT + ENTER

### Download excel file for this tutorial.

Sum data in a range.xls

(Excel 97-2003 Workbook *.xls)

### Functions in this article:

**SUM(**number1,[number2],**)
**Adds all the numbers in a range of cells

**IF(**logical_test;[value_if:true];[value_if_false]**)
**Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE

### 16 Responses to “Sum values in a range where adjacent cell value equals a criterion in excel”

### Leave a Reply

**How to add vba code to your comment:**

[vb 1="vbnet" language=","]

your code

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org

Add picture link to comment.

**Contact Oscar**

You can contact me through this webpage

This doesn't appear to work if you move the query to another sheet and reference the original sheet :(

Robin,

I am sure it does, can you provide the formula?

Hi Oscar,

Hope you are doing very well.

I am having trouble with my SUM IF function and was hoping you could help me out.

Here is the equation I am using.

=SUMIF('Data Entry Table'!C3:C1000, "=A4", 'Data Entry Table'!I3:I1000)

What I am trying to do here is:

- Working in Sheet 2, I am calling upon all the values in Sheet 1 that are identical to 'A4' in Sheet 2.

- Then I am adding numbers from an adjacent column that correspond to 'A4'.

The issue I am having is, A4 can change depending on what the user enters. I want the text in A4 (the content) rather than the address.

So for example, 'Blue' is entered in Sheet 1 multiple times in a column along with other colour names. In Sheet 2, I have a macro that compiles all the unique values... so Blue, Red, Green, etc. Now, still in Sheet 2, I want to add all the numbers in an adjacent column in Sheet 1 that are associated with a given colour and output that in Sheet 2.

I do not know what the 'colour name' will be, nor how many instances of each I will have.

I'm using colour name just as an example.

I hope I have explained this clearly.

Please let me know if you need further information from my end.

I am thinking that I cannot do what I would like with this equation, but maybe you have an alternate way of how I can achieve this?

Thank you for your time and efforts in advance.

Kindest regards,

Saad

Saad,

I am having trouble with my SUM IF function and was hoping you could help me out.Here is the equation I am using.

=SUMIF('Data Entry Table'!C3:C1000, "=A4", 'Data Entry Table'!I3:I1000)

What I am trying to do here is:

- Working in Sheet 2, I am calling upon all the values in Sheet 1 that are identical to 'A4' in Sheet 2.

- Then I am adding numbers from an adjacent column that correspond to 'A4'.

The issue I am having is, A4 can change depending on what the user enters. I want the text in A4 (the content) rather than the address.

I am not sure I understand. Is A4 a cell reference or a value?

So for example, 'Blue' is entered in Sheet 1 multiple times in a column along with other colour names. In Sheet 2, I have a macro that compiles all the unique values... so Blue, Red, Green, etc. Now, still in Sheet 2, I want to add all the numbers in an adjacent column in Sheet 1 that are associated with a given colour and output that in Sheet 2.I do not know what the 'colour name' will be, nor how many instances of each I will have.

I'm using colour name just as an example.

Is this what you are looking for?

Thankyou thankyou thankyou! :) This works brilliantly and the way you explained it made it really easy to implement!

Orion,

Thank you for commenting!

Hi Oscar,

I am trying to figure out how to create a formula and I was wondering if you could help.

I have one column with values (check amounts received) and the column next to it has the date those checks were received. For quarter end purposes, I want to add the values of checks up only if they were received after a certain date to get my accounts receivable number at quarter end. For example I have 10 checks for $1,000 each, but only 4 were received before 12/31/12, my accounts receivable would need to be $6,000. Is that possible?

Thanks!

Beth,

Download excel *.xlsx file

Beth2.xlsx

Hello Oscar,

Hope you are doing very well!

I apologize for such a delayed response to your posting - I had not realized that you had already responded a long time ago (I clicked the 'Notify me of followup comments via e-mail' but unfortunately did not receive notification).

Nevertheless, I wanted to sincerely thank you for your response and let you know that it was extremely helpful and I was able to solve my problem based on your input! The problem with my formula was that I had put quotations around =A4. Once I saw that you had not included quotations, I made the change and it worked!

Honestly, I really appreciate you taking out the time. It is comforting to know that there are people like you that are kind enough to spend their precious time helping others.

Thank you so much, Oscar!

I wish you all the best!

Kindest regards,

Saad

maybe you can help me been stuck in a rut for a few days now. essentially what im trying to do is have excel take the sum across a certain cell in the entire workbook if on a certain worksheet a value is entered into a certain cell. i hope i have explained this where you can comprehend. im fairly new to working with excel so its a little hard to explain.

Hi Oscar,

In column A, I have a long random list of two variables, "N/A" and the value 1. In column B I want to identify the number of contiguous occurrences of the value 1 before the next appearance of "N/A". I wonder if you could point me to the best way of achieving this please? Example below shows what I am after.

Much appreciation for your excellent website,

David

Col A Col B

N/A

N/A

1

1

1

1

1 5

N/A

1

1

1

1 4

N/A

N/A

1

1 2

N/A

N/A

N/A

1 1

In the example above, the space between the column of data in col A and the desired results, viz the 5, 4, 2 and 1 in col B got lost. Hope you can see what I'm after. Thanks.

hi guys,

i downloaded the sample excel sheet.why do i get the #value! error after i double clicked the c19 cell and pressed enter?

OSCAR,

YOU ARE A BRILLIANT MIND JUST HAD TO COMMENT THANKS ALOT. YOU DONT KNOW HOW MUCH HEAD ACHE I HAVE GONE THROUGH.

CHEERS!!

Hello Oscar,

I have data in multiple columns and I'm trying to create an equation that will sum the numbers in one column if the conditions in two other columns are met. Example:

In column A, there are different names, in column B there are other names, and in column C there are numbers. I want to add the numbers in column C only if the name in column A matches the name in column B. If A=B then SumC.

Column A Column B Column C

Full Name 1 Break 1124

Full Name 2 Home 3698

Full Name 3 Break 2136

In the above example. I want to add the values in Column C for Full Name 1 and "Break" in Column B. So the result should be 3260.

This is great. Thanks!