How to calculate average ratings of variable lists

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
1,447
Office Version
  1. 365
Platform
  1. Windows
I need to keep track of a series of ratings of several products. Each product will have one or more ratings on either a 0-10 or 0-100 scale. The number of ratings for each product will vary from 1 to some unknown number (probably less that 100).

Here's some sample data.

1608617097481.png


The only thing I could come up with is a little UDF to do the average. Here's that code:

VBA Code:
Function ListCalc(pList)

Dim ListArray() As String
ListArray = Split(pList, " ")

Dim ListSum As Double
ListSum = 0

Dim ListCount As Long
ListCount = UBound(ListArray)

Dim i As Long
For i = 0 To ListCount
    ListSum = ListSum + CDbl(ListArray(i))
Next i

ListCalc = ListSum / (ListCount + 1)

End Function

Is there a better way?

Thanks
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

StephenCrump

MrExcel MVP
Joined
Sep 18, 2013
Messages
4,124
Office Version
  1. 365
Platform
  1. Windows
A formula way:

AB
130.000030 40 20
252.375050 56 47 43 59 48 62 54
Sheet1
Cell Formulas
RangeFormula
A1:A2A1=AVERAGE(MyNumbers)

MyNumbers: =EVALUATE("{"&SUBSTITUTE(TRIM(!B1)," ",",")&"}")
(For cell A1, i.e. relative reference is to cell on the right - adjust as required)
 

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
1,447
Office Version
  1. 365
Platform
  1. Windows
A formula way:

AB
130.000030 40 20
252.375050 56 47 43 59 48 62 54
Sheet1
Cell Formulas
RangeFormula
A1:A2A1=AVERAGE(MyNumbers)

MyNumbers: =EVALUATE("{"&SUBSTITUTE(TRIM(!B1)," ",",")&"}")
(For cell A1, i.e. relative reference is to cell on the right - adjust as required)
I get a "That function isn't valid" error message.
 

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
1,447
Office Version
  1. 365
Platform
  1. Windows
After doing a little research, it appears that the Evaluate function is an old function that it still more or less supported, but must be used "in the confines of a named range".
 

StephenCrump

MrExcel MVP
Joined
Sep 18, 2013
Messages
4,124
Office Version
  1. 365
Platform
  1. Windows
After doing a little research, it appears that the Evaluate function is an old function that it still more or less supported, but must be used "in the confines of a named range".
Correct. So with the cursor in A1, select Name Manager/New ...
and define MyNumbers: =EVALUATE("{"&SUBSTITUTE(TRIM(!B1)," ",",")&"}")
 
Solution

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
1,447
Office Version
  1. 365
Platform
  1. Windows
Interesting. This is weird even for Excel. o_O I think I'll stick with my UDF, At least I more or less understand what it is doing.

Thanks
 

Watch MrExcel Video

Forum statistics

Threads
1,129,493
Messages
5,636,639
Members
416,932
Latest member
mm07

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
Top