7

I am using SUMIFS and want the sum_range dynamically to change according to the name I have of a column.

I have a table with about 100 columns. Say one of these columns is Paid_BC_items. I want a formula that looks for which column Paid_BC_items is in and somehow insert that into the SUMIF here where the Sheet4!J:J part is. I have a few other criteria here too which are fixed so they don't need to be dynamic.

=SUMIFS(Sheet4!J:J,Sheet4!$C:$C,Sheet2!$D$3,Sheet4!$E:$E, Sheet2!$C6, Sheet4!$G:$G, Sheet2!$D6)

If for example I changed the column heading to something else I want the SUMIF then to look for that column in the big tables and return that.

I know it has something to do with indexing, matching and indirects but I just can't figure it out right now.

Year    Week    Total Orders    Paid_BC_items   Free_BC_items
2014    1   971     147 104
2014    2   1565    339 213
2014    3   1289    391 209
2014    4   1171    389 228
2014    5   1163    375 240
2014    6   1298    405 330
2014    7   1233    404 292
pnuts
  • 58,317
  • 11
  • 87
  • 139
James Adams
  • 331
  • 1
  • 5
  • 18

2 Answers2

20

Try using this in place of the sum range

INDEX(Sheet4!A:DZ,0,MATCH("Paid_BC_Items",A1:DZ1,0))

when you use INDEX with 0 as the row argument you get the whole column....and MATCH picks the right column based on the header

Whole formula becomes:

=SUMIFS(INDEX(Sheet4!A:DZ,0,MATCH("Paid_BC_Items",A1:DZ1,0)),Sheet4!$C:$C,Sheet2!$D$3,Sheet4!$E:$E, Sheet2!$C6, Sheet4!$G:$G, Sheet2!$D6)

barry houdini
  • 45,615
  • 8
  • 63
  • 81
0

to make dynamic & be able to drag across for all column headings

MATCH(indirect(d$1),A1:DZ1,0))
Stevy
  • 3,228
  • 7
  • 22
  • 38