Best way to perform calculations on a list of numbers in a cell?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,535
Office Version
  1. 365
Platform
  1. Windows
I did a search and came up with the solution below to perform calculations on a list of numbers in a single cell. Is there a better way?

Mr Excel.xlsx
BCD
4WeightsAverageCount
565 64 68 62 69 7066.336
664 65 64 65 64 65 64 6564.508
75555.001
864 65 6665.003
Cell Average
Cell Formulas
RangeFormula
C5:C8C5=AVERAGE(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
D5:D8D5=COUNT(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))


Thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
That's a pretty good way to do it. The only thing better would be to put each number in one cell.
 
Upvote 0
That's a pretty good way to do it. The only thing better would be to put each number in one cell.
The problem with that is that the number of numbers varies. I suppose I could create enough columns for the maximum number, but that would take up more space.
 
Upvote 0
Another option (probably not better) would be to use a double negative in front of TEXTSPLIT.

Book1
ABC
1WeightsAverageCount
265 64 68 62 69 7066.333333336
364 65 64 65 64 65 64 6564.58
455551
564 65 66653
Sheet4
Cell Formulas
RangeFormula
B2:B5B2=AVERAGE(--TEXTSPLIT([@Weights]," "))
C2:C5C2=COUNT(--TEXTSPLIT([@Weights]," "))
 
Upvote 0
Another option (probably not better) would be to use a double negative in front of TEXTSPLIT.

Book1
ABC
1WeightsAverageCount
265 64 68 62 69 7066.333333336
364 65 64 65 64 65 64 6564.58
455551
564 65 66653
Sheet4
Cell Formulas
RangeFormula
B2:B5B2=AVERAGE(--TEXTSPLIT([@Weights]," "))
C2:C5C2=COUNT(--TEXTSPLIT([@Weights]," "))
I've noticed that before. I guess the first "-" converts text to negative numbers and the second converts those to positive. Right?

But why doesn't a "+" sign work?

Mr Excel.xlsx
BCDEF
4WeightsAverageCountAverage2Average3
565 64 68 62 69 7066.33666.33#DIV/0!
664 65 64 65 64 65 64 6564.50864.50#DIV/0!
75555.00155.00#DIV/0!
864 65 6665.00365.00#DIV/0!
95 3 0 -11.7541.75#DIV/0!
1-Cell Calulations
Cell Formulas
RangeFormula
C5:C9C5=AVERAGE(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
D5:D9D5=COUNT(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
E5:E9E5=AVERAGE(--TEXTSPLIT([@Weights]," "))
F5:F9F5=AVERAGE(+TEXTSPLIT([@Weights]," "))
 
Upvote 0
Yes you are right about the double negative. You could also multiple by one or add 0.
My guess is that by just putting a + in front of a text number doesn't change its value where as performing a mathematical operation will change it to a value.


Book1
ABC
1WeightsAverageCount
265 64 68 62 69 7066.333333336
364 65 64 65 64 65 64 6564.58
455551
564 65 66653
Sheet4
Cell Formulas
RangeFormula
B2:B5B2=AVERAGE(TEXTSPLIT([@Weights]," ")*1)
C2:C5C2=COUNT(--TEXTSPLIT([@Weights]," "))
 
Upvote 0
Here's is a table of the various methods discussed herein. Thanks for all of the comments and suggestions.

Mr Excel.xlsx
BCDEFGHI
4WeightsCountSumNumbervalue Average-- Average1* Average0+ Average+ Average
565 64 68 62 69 70639866.3366.3366.3366.33#DIV/0!
664 65 64 65 64 65 64 65851664.5064.5064.5064.50#DIV/0!
75515555.0055.0055.0055.00#DIV/0!
864 65 66319565.0065.0065.0065.00#DIV/0!
95 3 0 -1471.751.751.751.75#DIV/0!
1-Cell Calulations
Cell Formulas
RangeFormula
C5:C9C5=COUNT(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
D5:D9D5=SUM(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
E5:E9E5=AVERAGE(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
F5:F9F5=AVERAGE(--TEXTSPLIT([@Weights]," "))
G5:G9G5=AVERAGE(1*TEXTSPLIT([@Weights]," "))
H5:H9H5=AVERAGE(0+TEXTSPLIT([@Weights]," "))
I5:I9I5=AVERAGE(+TEXTSPLIT([@Weights]," "))
 
Upvote 0
Upvote 0
As @AhoyNC indicated Excel seems to ignore any "+" signs that aren't involved in a mathmatical operation.
Ok. Here's a more complete table.

Mr Excel.xlsx
BCDEFGHIJK
4WeightsCountSumNumbervalue Average-- Average1* Average0+ Average/1 Average^1 Average+ Average
565 64 68 62 69 70639866.3366.3366.3366.3366.3366.33#DIV/0!
664 65 64 65 64 65 64 65851664.5064.5064.5064.5064.5064.50#DIV/0!
75515555.0055.0055.0055.0055.0055.00#DIV/0!
864 65 66319565.0065.0065.0065.0065.0065.00#DIV/0!
95 3 0 -1471.751.751.751.751.751.75#DIV/0!
1-Cell Calulations
Cell Formulas
RangeFormula
C5:C9C5=COUNT(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
D5:D9D5=SUM(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
E5:E9E5=AVERAGE(NUMBERVALUE(TEXTSPLIT([@Weights]," ")))
F5:F9F5=AVERAGE(--TEXTSPLIT([@Weights]," "))
G5:G9G5=AVERAGE(1*TEXTSPLIT([@Weights]," "))
H5:H9H5=AVERAGE(0+TEXTSPLIT([@Weights]," "))
I5:I9I5=AVERAGE(TEXTSPLIT([@Weights]," ")/1)
J5:J9J5=AVERAGE(TEXTSPLIT([@Weights]," ")^1)
K5:K9K5=AVERAGE(+TEXTSPLIT([@Weights]," "))
 
Upvote 0

Forum statistics

Threads
1,215,409
Messages
6,124,743
Members
449,186
Latest member
HBryant

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