+ Reply to Thread
Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    10-09-2007
    Posts
    9

    Taking a number and creating a text value for it in another column

    Hello,

    I have a column of numeric values and would like in another column to display a text character based on the value of that number.

    For example if number is between 0 and 12 in column A (cell A1) display D in column B (cell B1). Else, if the number is between 13 and 26 display C instead.

    Does anyone know how I would go about doing this? I havn't got any experience of using VB so if thats needed posting the code would be great.

    Thanks for your time,

    Martin

  2. #2
    Forum Guru VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    12,009
    Maybe

    =IF(A1="","",LOOKUP(A1,{0,13},{"D","C"}))
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Moderator dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003 & 2007
    Posts
    3,661

    Smile

    Good morning Martin84

    Is your data ever going to return a minus number, or a number greater than 26? If so, this formula will just return a blank instead of an error :
    =IF(AND(A1>=0,A1<=12)=TRUE,"D",IF(AND(A1>=13,A1<=26)=TRUE,"C",""))

    HTH

    DominicB
    Now available : Ultimate Add-In 2007
    Integrates directly into the Office Excel Ribbon


    Download Ultimate Add-In v1.52 from www.dom-and-lis.co.uk
    90+ Utilities, 200+ Sub utilities last updated 25th April 2008
    Free!!

  4. #4
    Registered User
    Join Date
    10-09-2007
    Posts
    9
    Hi, no it wont run into negative numbers. Just found the data I am working with is:

    (Column A) (Column B output)

    6-8 F
    16 - 18 C
    23 - 26 A


    Just dont know how to put this into Excel

    Thanks

  5. #5
    Registered User
    Join Date
    10-09-2007
    Posts
    9
    F
    C
    A

    is the column B output i want, the spaces got cut out when I posted

  6. #6
    Forum Moderator Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    5,213
    Hi Martin, try this formula based on your new info:
    Code:
    =IF(AND(A1>=6,A1<=8),"F",IF(AND(A1>=16,A1<=18),"C",IF(AND(A1>=23,A1<=26),"A","")))

  7. #7
    Registered User
    Join Date
    10-09-2007
    Posts
    9
    Thanks pjoaquin, that worked fine.

  8. #8
    Registered User
    Join Date
    10-09-2007
    Posts
    9

    Getting a percentage value from letters

    Hi, I have a spreadsheet that applies the letters either A*, A, B, C to a cell depending on the numeric value of the cell next to it (see attached). What I need to do is to work out an amount showing the percentage of say B entries from all the entries in the 'Grades' column. I have no idea how to do this, can someone please find the time to help? A working formula would be great.

    Thanks,

    Martin
    Attached Files Attached Files

  9. #9
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138
    In column D, get rid of the colons, and change "A*" to "A~*"

    In E6 and copy down, =COUNTIF($C$5:$C$34, D6)/ROWS($C$5:$C$34)

    Code:
       -D- --------------------E---------------------
     6 A~* =COUNTIF($C$5:$C$34, D6)/ROWS($C$5:$C$34) 
     7 A   =COUNTIF($C$5:$C$34, D7)/ROWS($C$5:$C$34) 
     8 B   =COUNTIF($C$5:$C$34, D8)/ROWS($C$5:$C$34) 
     9 C   =COUNTIF($C$5:$C$34, D9)/ROWS($C$5:$C$34) 
    10 D   =COUNTIF($C$5:$C$34, D10)/ROWS($C$5:$C$34)
    Code:
       -D- -E-
     6 A~* 13%
     7 A   40%
     8 B   43%
     9 C    3%
    10 D    0%

  10. #10
    Registered User
    Join Date
    10-09-2007
    Posts
    9
    Thanks, for the value of 'A' results that gave me the number 0.4 which I assume is 40 %. Is there any way to make this read '40' or '40 %' instead, or have another calculation to translate it?

    Thanks

  11. #11
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,138
    Format > Cells > Number > Percentage, and pick the number of decimal places you want.

Thread Information

Users Browsing this Thread

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

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