+ Reply to Thread
Results 1 to 8 of 8

Replace words by numbers and calculate mean

  1. #1
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Replace words by numbers and calculate mean

    Hello,

    I have a list of words in one column with a number assigned to each of them in another column, in another column I have several of those words of the list (and others that are not in the list) and I'm trying to calculate the mean of each cell, only using the words that are in the list, as in the example that I attach, "blue" and "green" are not in the list so I don't have to consider them for the calculation of the mean of A2.
    I tried to find and replace simoultanously but doesn't work, I have more than 100000 rows in the "text" column and several thousands of words in the "word" column..
    Attached Files Attached Files

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Replace words by numbers and calculate mean

    =sum($e$2:$e$31*isnumber(find($d$2:$d$31,a2)))/sum(--isnumber(find($d$2:$d$31,a2))) cse

  3. #3
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Re: Replace words by numbers and calculate mean

    Thanks a lot tim201110! but I could not make it work, I get the division by zero error I think it is because the
    Please Login or Register  to view this content.
    doesn't work, it must find all values in
    Please Login or Register  to view this content.
    in a2 but when I test it alone
    Please Login or Register  to view this content.
    I get error. I tried to solve it with this
    https://exceljet.net/formula/range-c...-specific-text
    but does not work

  4. #4
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Replace words by numbers and calculate mean

    with a space on the right
    it is more accurate
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Re: Replace words by numbers and calculate mean

    Thanks a lot!!!!!

  6. #6
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Re: Replace words by numbers and calculate mean

    I thought that the problem was solved, but now I'm trying the formula with more data and it is not working fine.
    Here I attach the old excel file (points.xls) and the new one (points3.xls)
    In points3.xls I tested the words in A2: "Getting ready for lights out" and the result for this should be 5,684 as shown in K7, but the formula calculates 5,13 as shown in G2.
    I attach both files.. I think that the problem is that now in points3.xls it finds more words in D column that match those in A2 for example it finds "ready" but it also finds "already" and uses both of them to calculate the average.. but I can't find out how to solve that
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Replace words by numbers and calculate mean

    Try this one in G2, array confrmed with Shift Ctrl Enter.

    =AVERAGE(IFERROR($E$2:$E$10223/ISNUMBER(FIND(" "&$D$2:$D$10223&" "," "&A2&" ")),""))

    Is that what you need?

    edit:-

    I think you might actually need

    =AVERAGE(IFERROR($E$2:$E$10223/ISNUMBER(SEARCH(" "&$D$2:$D$10223&" "," "&A2&" ")),""))

    The FIND function which tim suggested is case sensitive, so will not match "Getting" to "getting".
    Last edited by jason.b75; 02-15-2019 at 04:42 PM.

  8. #8
    Registered User
    Join Date
    06-26-2016
    Location
    Barcelona
    MS-Off Ver
    Office 2007
    Posts
    21

    Re: Replace words by numbers and calculate mean

    Thanks a lot works great!

+ 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. [SOLVED] How to automatically replace certain words with other words?
    By Dieterl in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-13-2018, 12:12 AM
  2. Replies: 3
    Last Post: 11-09-2018, 05:14 PM
  3. Find and replace parts in string with words, numbers from a table
    By moosmahna in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-26-2017, 11:54 AM
  4. [SOLVED] Replace words with numbers based on strict rules
    By xbr088 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 09:22 AM
  5. Excel 2007 : replace words with numbers
    By gomes. in forum Excel General
    Replies: 11
    Last Post: 03-02-2010, 02:22 PM
  6. [SOLVED] How to Replace multiple words to replace using excell
    By ramsun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-10-2006, 08:55 AM
  7. IF formula in Excel / Replace numbers with 'words'
    By Emsmaps in forum Excel General
    Replies: 1
    Last Post: 04-07-2006, 06:01 PM

Tags for this Thread

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