# How to calculate average ratings of variable lists

#### JenniferMurphy

##### Well-known Member
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.

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

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

#### StephenCrump

##### MrExcel MVP
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
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
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
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)," ",",")&"}")

#### JenniferMurphy

##### Well-known Member
Interesting. This is weird even for Excel. I think I'll stick with my UDF, At least I more or less understand what it is doing.

Thanks

Replies
8
Views
219
Replies
3
Views
134
Replies
2
Views
201
Replies
0
Views
94
Replies
0
Views
38

1,129,371
Messages
5,635,876
Members
416,886
Latest member
coreyalaurence37

### 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.

### Which adblocker are you using?

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

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