How to calculate average ratings of variable lists

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,525
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 is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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)
 
Upvote 0
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.
 
Upvote 0
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".
 
Upvote 0
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)," ",",")&"}")
 
Upvote 0
Solution
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
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,391
Members
448,957
Latest member
Hat4Life

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