Formula to reference table column

Jetx227

Board Regular
Joined
Jul 11, 2018
Messages
96
Hi all!
I'm not great with formulas so I was looking for some help on this. I have a table (call it table1) and I have a cell that has a formula that references the sales columns within the table (because of the way the sales work, there are multiple sales columns, lets call them "Sales Total", "Sales 1", "Sales 2", and "Sales 3". I have a cell (D4) on my worksheet that allows the user to choose "All", "1", "2", or "3". Right now, the formula I have uses a long SUMIFS statement, basically checking that if the uses chooses "1", then sum from "Sales 1", etc. Is there a way to make this formula shorter and somehow use the text from D4 (the user chosen value) to reference the column? ie: "Sales " & D4 or something? Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Just want to let anyone who was curious that I figured it out by using the INDIRECT() function. So an example formula, if I wanted to sum the table column that the user chose would be (note, D4 is where the user's choice is):
VBA Code:
=SUM(INDIRECT("Table1[Sales " & $D$4 & "]"))
Credit to this article:
Indirectly Refer to Table Columns
 
Upvote 0

Forum statistics

Threads
1,214,892
Messages
6,122,112
Members
449,066
Latest member
Andyg666

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