+ Reply to Thread
Results 1 to 9 of 9

AVERAGE of comma separated numbers in a single cell

  1. #1
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    AVERAGE of comma separated numbers in a single cell

    I have a number of cells that contain comma separated lists of numbers in them.
    The lists are of varying lengths, and theoretically some of the numbers could be double-digits.

    For example:

    A1 = 1,1,1,2,1,5,3
    B1 = 2,10,4
    etc.

    I would like to find the average of each cell, as well as the overall average of all cells.

    I realise I could use text-to-columns, but the data needs to remain as it is.

    Thank you.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,228

    Re: AVERAGE of comma separated numbers in a single cell

    Please Login or Register  to view this content.
    =Ave_cell($a1)

    =Sum_cell($a1)



    Copy the Excel VBA code
    Select the workbook in which you want to store the Excel VBA code
    Press Alt+F11 to open the Visual Basic Editor
    Choose Insert > Module
    Edit > Paste the macro into the module that appeared
    Close the VBEditor
    Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
    [B][I]
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: AVERAGE of comma separated numbers in a single cell

    Thanks John.

    The Ave_cell results don't appear to be correct - they show as 2.333 and 8 respectively, but should be 2 and 5.333 ?
    I'm guessing it's because the divisor is including the comma count?

    Also, can these be adapted to accept a range as well as a single cell?

  4. #4
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,914

    Re: AVERAGE of comma separated numbers in a single cell

    Or try this ...

    =IFERROR(AVERAGE(--MID(SUBSTITUTE(","&A1,",",REPT(" ",LEN(A1))),
    ROW(INDIRECT("1:"&LEN(A1)-LEN(SUBSTITUTE(A1,",",""))+1))*LEN(A1),LEN(A1))),A1)

    Enter with Ctrl+Shift+Enter.

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: AVERAGE of comma separated numbers in a single cell

    Array entered

    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    v A B
    1 1,1,1,2,1,5,3 2.0
    2 2,10,4 5.3
    3
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,228

    Re: AVERAGE of comma separated numbers in a single cell

    .... should be

    in AVE_CELL function

    Ave_Cell = Ave_Cell / (UBound(LArray) + 1)

    Please give example of a range requirement.

  7. #7
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: AVERAGE of comma separated numbers in a single cell

    Quote Originally Posted by JohnTopley View Post
    Please give example of a range requirement.
    Using the same example file with similar comma separated lists in A1:A10 ... =Ave_Cell(A1:A10) etc.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,228

    Re: AVERAGE of comma separated numbers in a single cell

    Please Login or Register  to view this content.
    =ave_range(A1:a10)

  9. #9
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: AVERAGE of comma separated numbers in a single cell

    Quote Originally Posted by JohnTopley View Post
    =ave_range(A1:a10)
    Perfect. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 04-19-2017, 03:18 PM
  2. Lowest number in comma separated list from a single cell
    By jwrobel in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-30-2017, 03:27 AM
  3. [SOLVED] Loop through numbers separated by comma in a single cell
    By vpan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2017, 10:02 AM
  4. Selecting Lowest Number from Data in a Single Cell Separated by Comma
    By hasanrazaque in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-07-2016, 12:13 AM
  5. [SOLVED] Using comma separated values in a single cell
    By joerobb in forum Excel General
    Replies: 7
    Last Post: 01-16-2015, 08:45 AM
  6. Match a Value from a single-cell, comma separated list
    By secondchild12 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-24-2014, 06:16 PM
  7. Column/cells to single cell comma separated data?
    By egeorge4 in forum Excel General
    Replies: 1
    Last Post: 04-27-2007, 03:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1