Excel Table - change the column I'm summing based on a variable

excel_mills

New Member
Joined
Feb 8, 2014
Messages
2
I have 2 tables: table 1 which contains a summary; table 2 which contains my data

I want to be able to look up and sum the total of a column in table 2 based on the value in table 1 (ie. I need to be able to change the syntax in the formula "=SUM(table2[column])"

To give an example, here is my first table:

A B*
Apples =sum(table2[@A])
Bananas =sum(table2[@A])
Pears =sum(table2[@A])

In table 2, I have column headings "Apples", "Bananas, "Pears".

Is this even possible? I have tried using the INDIRECT function and "" but none of these seem to work.

I'm relatively new to Excel and keen to learn, so any help would be greatly appreciated. I hope my example of what I'm trying to do makes sense!

Thank you for your help

* Column A contains "Apples", "Pears", etc
* Column B contains my formula
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Maybe...

Formula in B2
=SUM(INDEX(table2,0,MATCH(A2,table2[#Headers],0)))
copy down

Assumes A2=Apples; A3=Bananas;....

M.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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