Using the results of a formula as part of a new formula

xcl1997

New Member
Joined
Sep 12, 2022
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Is there a way to turn C4 into a formula that actually performs a sum range of the result produced by the formula that's already in the cell? Referencing C4 in a sum range from another cell works (for example, [SUM(INDIRECT(C4))] in C5 produces the correct value of "0"). But is there a way to do it all within the same cell?

9-16-22 MrExcel.xlsx
CDEFGHIJKL
4'Daily Tally'!G7702:G7722'Daily Tally'!H7702:H7722'Daily Tally'!I7702:I7722'Daily Tally'!J7702:J7722'Daily Tally'!K7702:K7722'Daily Tally'!L7702:L7722'Daily Tally'!M7702:M7722'Daily Tally'!N7702:N7722'Daily Tally'!O7702:O7722'Daily Tally'!P7702:P7722
50000000002.25
Sheet1
Cell Formulas
RangeFormula
C4:HR4C4="'Daily Tally'!"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B389,'Daily Tally'!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B389+1,'Daily Tally'!A:A,0)-1
C5:L5C5=SUM(INDIRECT(C4))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
DailyTallyData='Daily Tally'!$A$5:$D$6644C4
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Maybe
Excel Formula:
=SUM(INDIRECT("'Daily Tally'!"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B389,'Daily Tally'!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B389+1,'Daily Tally'!A:A,0)-1))
 
Upvote 0
Maybe
Excel Formula:
=SUM(INDIRECT("'Daily Tally'!"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B389,'Daily Tally'!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B389+1,'Daily Tally'!A:A,0)-1))
Not familiar with the "CODE=xls" part, and Excel won't let me enter it in a cell. But I tried the formula in between the CODE parts - it gave a value of "1", but the value should be "0". Also, it did not spill into other parts of row 4 as desired.
 
Upvote 0
Not familiar with the "CODE=xls" part, and Excel won't let me enter it in a cell. But I tried the formula in between the CODE parts - it gave a value of "1", but the value should be "0". Also, it did not spill into other parts of row 4 as desired.
Never mind my mention about the "CODE" part. I see that is just part of the code of the thread.
 
Upvote 0
In that case can you post some sample data from the Daily Tally sheet.
 
Upvote 0
In that case can you post some sample data from the Daily Tally sheet.
The first sample is a repost of Sheet1. To make things easier, the formula in question is now in C1. The second sample is from the Daily Tally sheet.

Spreadsheet A - (for upwork) Daily Diet Starting From 8-29-2021.xlsx
BCDEFGHIJKLMN
1 'DAILY TALLY'!G5:G22'DAILY TALLY'!H5:H22'DAILY TALLY'!I5:I22'DAILY TALLY'!J5:J22'DAILY TALLY'!K5:K22'DAILY TALLY'!L5:L22'DAILY TALLY'!M5:M22'DAILY TALLY'!N5:N22'DAILY TALLY'!O5:O22'DAILY TALLY'!P5:P22'DAILY TALLY'!Q5:Q22'DAILY TALLY'!R5:R22
2Daily average0.010.000.010.000.000.010.010.010.020.060.010.11
32x Chicken Burrito, white rice, pinto beans, hot salsa, lettuce; Chipotle2x Chicken Burrito, white rice, pinto beans, mild salsa, lettuce; Chipotle2x Pollo Asado Burrito, guac, white rice, pinto beans, hot salsa, lettuce; Chipotle2x Pollo Asado Burrito, white rice, pinto beans, hot salsa, lettuce; Chipotle3 Musketeers Fun Size Bars (30g)85% Cacao, classic blackout, organic dark chocolate, (4 sections=30g); alter eco86% Cacao, intense dark, dark chocolate, (3 pieces=34g); Ghirardelliall purpose unbleached flour, organic, 1/4 cup (30g); simply balancedAlmond milk, unsweetened, organic; 365Almond milk, unsweetened, vanilla, organic; 365Almondmilk, organic, unsweetened, organic; OrgainAlmondmilk, vanilla, unsweetened; Almond Breeze
4
5
6
7
88/28/2021sum: 2.001.003.001.000.302.672.624.186.3322.304.2642.78
98/29/20210.000.000.000.000.000.000.000.000.000.000.000.19
108/30/20210.000.000.000.000.000.000.000.000.000.000.000.19
Sheet1
Cell Formulas
RangeFormula
B1B1=IF(AND(SUM(INDIRECT(SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+1,4),"1","")&ROWS($A$1:$A$8)&":"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+1,4),"1","")&ROWS($A$1:$A$8)))=0,COLUMNS(INDIRECT("C3:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+2,4),"1","")&ROWS(A$1:A$3)))=FoodListUnitsCount),"NEED TO ADD SERVING FIELD FOR FOOD IN LAST COLUMN!!","")
C2:N2D2=SUM(INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMNS($A$1:D1),4),"1","")&"9:"&SUBSTITUTE(ADDRESS(1,COLUMNS($A$1:D1),4),"1","")&Sheet1lstrow))/ROWS(INDIRECT("$B$9:$b$"&Sheet1lstrow))
C1:HR1C1="'DAILY TALLY'!"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B9,'Daily Tally'!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B9+1,'Daily Tally'!A:A,0)-1
C3:HR3C3=TRANSPOSE(SORT(INDIRECT("'Food List & Units'!B2:B"&FoodListUnitsCount),1))
C8C8=CONCATENATE("sum: "&TEXT(SUM(INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMN(C9),4),"1","")&ROWS($C$1:$C9)&":"&SUBSTITUTE(ADDRESS(1,COLUMN(C9),4),"1","")&Sheet1lstrow))," 0.00"))
D8:N8D8=SUM(INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMN(D9),4),"1","")&ROWS($C$1:$C9)&":"&SUBSTITUTE(ADDRESS(1,COLUMN(D9),4),"1","")&Sheet1lstrow))
B9:B10B9=B8+1
C9:N10C9=IF($B9=MAX(INDIRECT("'Daily Tally'!A1:A"&DailyTallylstrwofsprdsht)),SUM(INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(C$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&XMATCH($B9,INDIRECT("'Daily Tally'!$A$1:$A"&DailyTallylstrwofsprdsht),0)):INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(C$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&DailyTallylstrwofsprdsht)),IF($B9<MAX(INDIRECT("'Daily Tally'!A1:A"&DailyTallylstrwofsprdsht)),SUM(INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(C$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&XMATCH($B9,INDIRECT("'Daily Tally'!$A$1:$A"&DailyTallylstrwofsprdsht),0)):INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(C$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&XMATCH($B9+1,INDIRECT("'Daily Tally'!$A$1:$A"&DailyTallylstrwofsprdsht),0)-1))))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
DailyTallyData='Daily Tally'!$A$5:$D$6644C1



Spreadsheet A - (for upwork) Daily Diet Starting From 8-29-2021.xlsx
ABCDEFGHIJKLMNOPQR
1
2SymbolUnits2x Chicken Burrito, white rice, pinto beans, hot salsa, lettuce; Chipotle2x Chicken Burrito, white rice, pinto beans, mild salsa, lettuce; Chipotle2x Pollo Asado Burrito, guac, white rice, pinto beans, hot salsa, lettuce; Chipotle2x Pollo Asado Burrito, white rice, pinto beans, hot salsa, lettuce; Chipotle3 Musketeers Fun Size Bars (30g)85% Cacao, classic blackout, organic dark chocolate, (4 sections=30g); alter eco86% Cacao, intense dark, dark chocolate, (3 pieces=34g); Ghirardelliall purpose unbleached flour, organic, 1/4 cup (30g); simply balancedAlmond milk, unsweetened, organic; 365Almond milk, unsweetened, vanilla, organic; 365Almondmilk, organic, unsweetened, organic; OrgainAlmondmilk, vanilla, unsweetened; Almond Breeze
3
4
58/29/2021ptcj33Premium Tortilla Chips, jalapeno cheddar, (20 chips=28g); Old Dutch Restaurant StyleCOPY FROM HERE BELOW (ROW 6)!8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
6pdc812Pure Dark Chocolate, 85% dark chocolate, 1/2 bar;4 squares=42g; theo Organic Fair Trade 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
7stpb17Spicy Thai Peanut Butter, (1 tbsp=14g); Eliot's 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
8oq&c60Organic Quinoa & Chia Seeds Supercereal, (1oz=28g); Awsum Snacks 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
9avua1.5Almondmilk, vanilla, unsweetened; Almond Breeze 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.19
10s-coo40Steel-Cut Oats, organic, (1/4 cup=40g); 365 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
11kscm0.0937Kosher Salt, coarse; Morton 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
12kscm0.0625Kosher Salt, coarse; Morton 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
13ctst0.5Chickpea Taco Salad... - TB12 Purple Carrot (low sug/salt/no avoc,oil, or dress/.5 tofu) 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
14dsem1Dietary Supplement, every man's One Daily Multi; New Chapter 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
15acrw0.367Avocados, California, raw, whole, peeled, average-size (4.8 oz without seed) 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
16pcgo70Polenta, Corn Grits, organic, (1/4 cup=46g); Bob's Red Mill 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
17mbd&8Medium Buffalo Dipping & Wing Sauce, (1 Tbsp=15g); Noble Made 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
18jsh11Jalapeno, sliced, hot, (12 slices=28g); Mrs. Renfro's 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
19wbps129Water, bottled (Poland Spring) 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
20tcbt10.5Tandoori Chickpea Burgers - TB12 Purple Carrot (NO OIL/low fat/sod/sug) 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
21aocp0.67Avocado Oil, cold pressed, naturally refined, (1 Tbsp = 14g); Choosen Foods 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
22sgfc112Spaghetti, gluten free, corn & rice, (56g=2oz); 365 8/29/20210.000.000.000.000.000.000.000.000.000.000.000.00
238/30/2021avua1.50Almondmilk, vanilla, unsweetened; Almond Breeze 8/30/20210.000.000.000.000.000.000.000.000.000.000.000.19
24cfrs1.00Cajun Fries, regular size; Popeye's 8/30/20210.000.000.000.000.000.000.000.000.000.000.000.00
Daily Tally
Cell Formulas
RangeFormula
G2:HV2G2=TRANSPOSE(SORT(INDIRECT("'Food List & Units'!B2:B"&FoodListUnitsCount),1))
D5:D7744D5=VLOOKUP(FILTER(INDIRECT("B5:B"&DailyTallylstrwofsprdsht),1),INDIRECT("'Food List & Units'!A2:B"&FoodListUnitsCount),2,0)
F5:F24F5=IF(AND(A4<>"",A5="",A6="",B6<>""),F4,IF(AND(A4="",A5<>"",A6="",B6<>""),A5,IF(AND(A4="",A5="",A6="",B6<>""),F4,IF(AND(A4="",A5="",A6<>"",B6<>""),F3,IF(AND(A4="",A5="",A6="",B6="",B5=""),"",IF(AND(A4="",A5="",A6="",B6="",B5<>""),F4+1))))))
G5:HV24G5=IF(TRANSPOSE(SORT(INDIRECT("'Food List & Units'!B2:B"&FoodListUnitsCount),1))=D5,C5/FILTER(INDIRECT("'Food List & Units'!C2:C"&FoodListUnitsCount),'Daily Tally'!B5=INDIRECT("'Food List & Units'!A2:A"&FoodListUnitsCount)),0)
E6:E24E6=IF(AND(B6<>"",SUM(INDIRECT("G"&ROWS(E$1:E6)&":"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS(E$1:E6)))=0),"need to add food","")
Dynamic array formulas.
Named Ranges
NameRefers ToCells
DailyTallyData='Daily Tally'!$A$5:$D$6644F5:F6
Cells with Conditional Formatting
CellConditionCell FormatStop If True
JI1:JM1,A1:F1,J1:FH1,FJ1:HU1,IX1:IZ1,JP1:JQ1,KQ1:XFD1,HW1:IN1Cell ValueduplicatestextNO
 
Upvote 0
There is so much going on in there & you are looking at other sheets, so I have no way to test this, but you could try
Excel Formula:
=BYCOL("'DAILY TALLY'!"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B9,'Daily Tally'!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B9+1,'Daily Tally'!A:A,0)-1,LAMBDA(bc,SUM(INDIRECT(bc))))
 
Upvote 0
There is so much going on in there & you are looking at other sheets, so I have no way to test this, but you could try
Excel Formula:
=BYCOL("'DAILY TALLY'!"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B9,'Daily Tally'!A:A,0)&":"&SUBSTITUTE(ADDRESS(1,MATCH(SORT('Daily Tally'!G2#),C3:HV3,0)+6,4),"1","")&XMATCH(B9+1,'Daily Tally'!A:A,0)-1,LAMBDA(bc,SUM(INDIRECT(bc))))
Plugging your formula into C4, the array shows the correct value in fk4, but incorrect values for all other non-zero cells. For reference, row 9 is the correct totals for each food for that date. Tried different dates in place of b9 in the formula, and it shows the formula is only giving non-zero values for the first food that shows up on the date in column D of the Daily Tally sheet.

Spreadsheet A - (for upwork) Daily Diet Starting From 8-29-2021.xlsx
EXEYEZFAFBFCFDFEFFFGFHFIFJFK
1'DAILY TALLY'!FB5:FB22'DAILY TALLY'!FC5:FC22'DAILY TALLY'!FD5:FD22'DAILY TALLY'!FE5:FE22'DAILY TALLY'!FF5:FF22'DAILY TALLY'!FG5:FG22'DAILY TALLY'!FH5:FH22'DAILY TALLY'!FI5:FI22'DAILY TALLY'!FJ5:FJ22'DAILY TALLY'!FK5:FK22'DAILY TALLY'!FL5:FL22'DAILY TALLY'!FM5:FM22'DAILY TALLY'!FN5:FN22'DAILY TALLY'!FO5:FO22
20.210.010.020.020.020.010.570.010.010.001.250.020.010.13
3Pineapple chunks, organic, (1 cup=140g); 365Pineapple, raw, slices, average (3-1/2" diameter x 3/4" thick, 3.0 oz)Pizza, pepperoni & sausage, 1/4 of 19.4oz pizza (138g); TombstonePizza, The Works, original-crust, medium, (1 slice); Papa John'sPizza, The Works, original-crust, small, (1 slice); Papa John'sPizza, vegan supreme, 1/3 pizza (132g); Amy'sPlant Calcium, Bone Strength, Take Care, Tiny Tabs; New ChapterPlant-Based chick'n noodl', (1 can=425g); gardeinPlant-Based Hamburger Helper Meal, Deluxe Cheeseburger MacaroniPlant-Based minestrone & saus'ge, (1 can=425g); gardeinPolenta, Corn Grits, organic, (1/4 cup=46g); Bob's Red MillPopcorn, cheese, 2.25 cups (28g); Old DutchPotato Chips, dill pickle, (57g) 2 oz bag; Old DutchPremium Tortilla Chips, jalapeno cheddar, (20 chips=28g); Old Dutch Restaurant Style
40.000.000.000.000.000.000.000.000.000.000.000.000.001.18
50.000.000.000.000.000.000.000.000.000.000.000.000.001.18
6
7
878.323.678.008.006.002.83219.002.002.001.00478.915.932.0049.35
90.000.000.000.000.000.000.000.000.000.001.520.000.001.18
Sheet1
Cell Formulas
RangeFormula
EX2:FK2EX2=SUM(INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMNS($A$1:EX1),4),"1","")&"9:"&SUBSTITUTE(ADDRESS(1,COLUMNS($A$1:EX1),4),"1","")&Sheet1lstrow))/ROWS(INDIRECT("$B$9:$b$"&Sheet1lstrow))
EX8:FK8EX8=SUM(INDIRECT(SUBSTITUTE(ADDRESS(1,COLUMN(EX9),4),"1","")&ROWS($C$1:$C9)&":"&SUBSTITUTE(ADDRESS(1,COLUMN(EX9),4),"1","")&Sheet1lstrow))
EX9:FK9EX9=IF($B9=MAX(INDIRECT("'Daily Tally'!A1:A"&DailyTallylstrwofsprdsht)),SUM(INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(EX$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&XMATCH($B9,INDIRECT("'Daily Tally'!$A$1:$A"&DailyTallylstrwofsprdsht),0)):INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(EX$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&DailyTallylstrwofsprdsht)),IF($B9<MAX(INDIRECT("'Daily Tally'!A1:A"&DailyTallylstrwofsprdsht)),SUM(INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(EX$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&XMATCH($B9,INDIRECT("'Daily Tally'!$A$1:$A"&DailyTallylstrwofsprdsht),0)):INDIRECT("'daily tally'!"&SUBSTITUTE(ADDRESS(1,XMATCH(EX$3,INDIRECT("'Daily Tally'!A2:"&SUBSTITUTE(ADDRESS(1,FoodListUnitsCount+5,4),"1","")&ROWS($A$1:$A$2)),0),4),"1","")&XMATCH($B9+1,INDIRECT("'Daily Tally'!$A$1:$A"&DailyTallylstrwofsprdsht),0)-1))))
 
Upvote 0
In that case I would suggest you stick with your original solution.
 
Upvote 0
In that case I would suggest you stick with your original solution.
Aw, come on. It's probably just an adjustment or two away from being correct. Will you give it one more shot?
 
Upvote 0

Forum statistics

Threads
1,215,330
Messages
6,124,305
Members
449,150
Latest member
NyDarR

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