sumif dynamic criteria range

Luigi802

Board Regular
Joined
Oct 16, 2014
Messages
80
So I'm trying to create a sumif formula that looks something like this =sumif(Sheet1[C4],C5,Sheet1[Column2])
So the "C4" in "Sheet1[C4]" is a dynamic value that corresponds to a column header name in a table, "C5" is obviously the criteria, and again obviously the "Sheet1[Column2]" is the column in which I want to sum. I've scoured the internet and just can't find what I'm looking for!:confused:
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
You seem to be confusing the sheet name with the table name. However, look at the following:

CDEFGHIJKL
1Column1Column2Column3Column1Column2Column3
2110a440b
3Table2220b550a
4Column3330c660c
5a
6
750

<tbody>
</tbody>
Sheet17

Worksheet Formulas
C7=SUMIF(INDIRECT(C3&"["&C4&"]"),C5,INDIRECT(C3&"[Column2]"))

<tbody>
</tbody>

<tbody>
</tbody>



E1:G4 is defined as Table1, and I1:K4 is Table2. Then you can use the formula in C7 to get a total based on the values in C3:C5. If this isn't exactly what you're looking for, you should be able to get the idea. The INDIRECT function is the key. Hope this helps.
 
Upvote 0
You seem to be confusing the sheet name with the table name. However, look at the following:

CDEFGHIJKL
1Column1Column2Column3Column1Column2Column3
2110a440b
3Table2220b550a
4Column3330c660c
5a
6
750

<tbody>
</tbody>
Sheet17

Worksheet Formulas
C7=SUMIF(INDIRECT(C3&"["&C4&"]"),C5,INDIRECT(C3&"[Column2]"))

<tbody>
</tbody>

<tbody>
</tbody>



E1:G4 is defined as Table1, and I1:K4 is Table2. Then you can use the formula in C7 to get a total based on the values in C3:C5. If this isn't exactly what you're looking for, you should be able to get the idea. The INDIRECT function is the key. Hope this helps.

Yeah sorry, I accidentally put the sheet name cause it's the same as my table name. Here's an example of what I'm trying to do

DayDateAmountDescriptionCategory
Sunday18-09-18563 A1c
Tuesday20-09-18567 A3d
Wednesday15-08-1823 B5t
Friday03-01-187 A6k
Saturday11-10-1812 C9f

<tbody>
</tbody>

So let's say this is my table (table1) so my formula would be something kinda like before =sumif(table1[C4],C5,table1[amount]) and C4 would be and 1 of the following table headers; Day, Date, Amount, Description, Category
So if C4 was "Category" and C5 was "5t" the result would be 23
I tried the formula you posted but if gave me a #REF! error
 
Last edited:
Upvote 0
This works for me:

ABCDEFGHIJ
1DayDateAmountDescriptionCategory
2Sunday9/18/2018563A1c
3Tuesday9/20/2018567A3d
4Search columnCategoryWednesday8/15/201823B5t
5Search value5tFriday1/3/20187A6k
6Sum23Saturday10/11/201812C9f

<tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
C6=SUMIF(INDIRECT("Table1["&C4&"]"),C5,Table1[Amount])

<tbody>
</tbody>

<tbody>
</tbody>



Change the values in C4 and C5, and the formula will show different results.

If you still have problems, what version of Excel do you have? Also, based on your date formats, you may have a version of Excel with different defaults. You might need to change all the commas in the formula to semicolons.
 
Upvote 0
This works for me:

ABCDEFGHIJ
1DayDateAmountDescriptionCategory
2Sunday9/18/2018563A1c
3Tuesday9/20/2018567A3d
4Search columnCategoryWednesday8/15/201823B5t
5Search value5tFriday1/3/20187A6k
6Sum23Saturday10/11/201812C9f

<tbody>
</tbody>
Sheet2

Worksheet Formulas
CellFormula
C6=SUMIF(INDIRECT("Table1["&C4&"]"),C5,Table1[Amount])

<tbody>
</tbody>

<tbody>
</tbody>



Change the values in C4 and C5, and the formula will show different results.

If you still have problems, what version of Excel do you have? Also, based on your date formats, you may have a version of Excel with different defaults. You might need to change all the commas in the formula to semicolons.


That simple huh? Well thank you very much that worked perfectly!
 
Upvote 0

Forum statistics

Threads
1,215,202
Messages
6,123,625
Members
449,109
Latest member
Sebas8956

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top