+ Reply to Thread
Results 1 to 10 of 10

Replace/Substitute/Exchange words to numbers

  1. #1
    Registered User
    Join Date
    09-20-2019
    Location
    Cebu, Philippines
    MS-Off Ver
    2016
    Posts
    44

    Replace/Substitute/Exchange words to numbers

    I was trying to get creative with the SWITCH function but I might have done it wrong.

    I have a large file where 1 column contains 4 specific words only but in random order - MINIMAL, LOW, MODERATE, HIGH. I need to 'assign' a number/value to each of those words:
    → 1 = Minimal
    → 2 = Low
    → 3 = Moderate
    → 4 = High

    I attached a sample file.

    Thanks.
    Attached Files Attached Files

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Replace/Substitute/Exchange words to numbers

    If I understand you correctly, try this...
    L5=VLOOKUP(K5,$H$5:$I$8,2,0)
    copied down as needed.

    If that wasnt what you wanted, plz provide some sample answers.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Replace/Substitute/Exchange words to numbers

    Or can be use sumifs too as the result is in numeric

    =SUMIFS($I$5:$I$8,$H$5:$H$8,K5)
    If I helped, Don't forget to add reputation (click on the little star ★ at bottom of this post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Replace/Substitute/Exchange words to numbers

    yuppers or just SUMIF...
    =SUMIF($H$5:$H$8,K5,$I$5:$I$8)

  5. #5
    Registered User
    Join Date
    09-20-2019
    Location
    Cebu, Philippines
    MS-Off Ver
    2016
    Posts
    44

    Re: Replace/Substitute/Exchange words to numbers

    The columns that has the header COLUMN 1 & 2 are the desired results. The file I have has up to Column AS and the column that has MINIMAL, LOW, MODERATE, HIGH is only 1 of them.

    So basically, these dont show on the file that I'm working on:
    Column 1 Column 2
    Minimal 1
    Low 2
    Moderate 3
    High 4

    I tried =SWITCH(K5, Minimal, "1", Low, "2", Moderate, "3", High, "4", 0) but it didnt work. So, I guess it only works if the value is a number...

  6. #6
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Replace/Substitute/Exchange words to numbers

    Yes Ford!!! I have practiced sumifs rather than sumif as sumifs is state forward Sumrange, CriteriaRange, Criteria but I must ignore this practice as if there is only one condition we must go with sumif only it is because if there is sumif then there must be some reason,

  7. #7
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Replace/Substitute/Exchange words to numbers

    May be you have entered wrongly text into switch function as text must be mention in " "

    Try
    =SWITCH(K5, "Minimal", 1, "Low", 2, "Moderate",3, "High",4)

    Have look at here https://exceljet.net/excel-functions...witch-function

  8. #8
    Registered User
    Join Date
    09-20-2019
    Location
    Cebu, Philippines
    MS-Off Ver
    2016
    Posts
    44

    Re: Replace/Substitute/Exchange words to numbers

    Oh gosh... how could I have missed that! Thank you!!!

  9. #9
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Replace/Substitute/Exchange words to numbers

    Then I suggest that you create a small table somewhere - like the 1 you showed, and then use vlookup...or 1 of the other suggestions...to get what you want. Why make things more complicated than they need to be (not all versions of excel have the SWITCH function - I dont)?

  10. #10
    Forum Expert shukla.ankur281190's Avatar
    Join Date
    05-17-2014
    Location
    Lucknow, India
    MS-Off Ver
    Office 365
    Posts
    3,937

    Re: Replace/Substitute/Exchange words to numbers

    Yes agree with Ford!!! I don't have too switch function in my excel version.

+ 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. Replace words by numbers and calculate mean II
    By anahochmanova in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-15-2019, 06:12 PM
  2. [SOLVED] Replace words by numbers and calculate mean
    By anahochmanova in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-15-2019, 05:30 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. How do I substitute numbers for certain words?
    By Pyrex238 in forum Excel General
    Replies: 1
    Last Post: 02-20-2012, 09:55 PM
  6. Excel 2007 : replace words with numbers
    By gomes. in forum Excel General
    Replies: 11
    Last Post: 03-02-2010, 02:22 PM
  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

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