Assign a letter to a number value within a specific range

assign a value or category based on a number range with formula
how do i assign values to text in excel and then add them
how to assign a value to a letter in excel
how do i assign a number value to a non-numeric value in excel
how to make text represent a number in excel
how to make a word represent a number in excel
vlookup
excel assign value to cell from another cell

a learning noobie here.

I am needing a script that can take a number value and assign a letter to it, depending on the range the value falls within. Please run the simple example below:

table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
}
<table>
  <tr>
    <th>Achieved mark</th>
    <th>Grade</th>    
  </tr>
  <tr>
    <td>Above 80 (max 100)</td>
    <td>A</td>    
  </tr>
  <tr>
  	<td>60-79</td>
    <td>B</td> 
  </tr>
  <tr>
  	<td>40-59</td>
    <td>C</td> 
  </tr>
  <tr>
  	<td>Below 39 (min 0)</td>
    <td>D</td> 
  </tr>  
</table>
<br>
<p>Enter achieved mark:</p>
<input type="input" id="mark" value="73">


<button onclick="myFunction()">GO!</button>

<p>Grade result:</p>

<input type="output" id="grade">

You can do it like this

First thing is you need to get the value of element that you can get by. document.getElementById('mark').value this expression.

Now based on this value you can calculate grade by simply using if conditions.

Than you need to assign it to your grade (input) that you can achieve by this document.getElementById('grade').value = grade

function myFunction(e){
 var ele = document.getElementById('mark').value;
 var grade ='';
 if(ele > 80){
  grade = 'A';
 } else if(ele <=79 && ele >=60){
  grade = 'B';
 } else if(ele <=59 && ele >=40){
  grade = 'C'
 } else {
  grade = 'D';
 }
 document.getElementById('grade').value = grade;
}
table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
}
<table>
  <tr>
    <th>Achieved mark</th>
    <th>Grade</th>    
  </tr>
  <tr>
    <td>Above 80 (max 100)</td>
    <td>A</td>    
  </tr>
  <tr>
  	<td>60-79</td>
    <td>B</td> 
  </tr>
  <tr>
  	<td>40-59</td>
    <td>C</td> 
  </tr>
  <tr>
  	<td>Below 39 (min 0)</td>
    <td>D</td> 
  </tr>  
</table>
<br>
<p>Enter achieved mark:</p>
<input type="input" id="mark" value="73">


<button onclick="myFunction()">GO!</button>

<p>Grade result:</p>

<input type="output" id="grade">

How to Use a Letter to Represent a Value in Excel, In Microsoft Excel, the well-known and widely used spreadsheet software, you can use which can return a value from a selected range (one row or column) or an array of cells. Type a letter in cell A1 and its corresponding value in cell B1. For example, if you defined six letters and their variables in the first six rows and  If you want to convert the integer numbers which are in the range of 1 to 26 to the corresponding letters, the following formula can do you a favor. 1. In a blank cell besides your data, for example, cell D3, please enter below formula, and press the Enter key. =MID ("ABCDEFGHIJKLMNOPQRSTUVWXYZ",B3,1)

Simple else if condition:

function myFunction() {
  var num = document.getElementById('mark').value;
  var result = 'A';

  num = Math.min(100, Math.max(0, num));
  
  if (num < 40) {
    result = 'D';
  } else if (num < 60) {
    result = 'C';
  } else if (num < 80) {
    result = 'B';
  }
  
  document.getElementById('grade').value = result;
}
table {
  font-family: arial, sans-serif;
  border-collapse: collapse;
  width: 100%;
}

td, th {
  border: 1px solid #dddddd;
  text-align: left;
  padding: 8px;
}
<table>
  <tr>
    <th>Achieved mark</th>
    <th>Grade</th>    
  </tr>
  <tr>
    <td>Above 80 (max 100)</td>
    <td>A</td>    
  </tr>
  <tr>
  	<td>60-79</td>
    <td>B</td> 
  </tr>
  <tr>
  	<td>40-59</td>
    <td>C</td> 
  </tr>
  <tr>
  	<td>Below 39 (min 0)</td>
    <td>D</td> 
  </tr>  
</table>
<br>
<p>Enter achieved mark:</p>
<input type="input" id="mark" value="73">


<button onclick="myFunction()">GO!</button>

<p>Grade result:</p>

<input type="output" id="grade">

assigning a letter to a number range, This Week's Hot Topics. Search a value in a column-B and return the values from column-A. Started by i200yrs; Jun  Re: Assigning letters in a column a certain numerical value within a lookup formula Yes you are correct. That is the formula I have but it is only looking at specific rows A4 - A6 because I have organized my list.

Return a string based on the current grade.

const myFunction = (grade) => {
  let mark = null;
  if (grade >= 80 && grade <= 100) {
    mark = 'A';
  } else if (grade >= 60 && grade <= 79) {
    mark = 'B';
  } else if (grade >= 40 && grade <= 59) {
    mark = 'C'
  } else if (grade <= 39) {
    mark = 'Dude?';
  } else {
    return false;
  }

  return mark;
}

const grade = myFunction(60);

console.log(grade);

Formulas in Microsoft Excel: How to Change a Letter Into a Number , To translate letters in a string to numbers, you can use an array formula based on the TEXTJOIN and VLOOKUP functions, with a defined translation table to provide the necessary lookups. where "xtable" is the named range E5:F10. The Excel TEXTJOIN function concatenates (joins) values with a given delimiter. a learning noobie here. I am needing a script that can take a number value and assign a letter to it, depending on the range the value falls within. Please run the simple example below: table

You can also try below one.

 const grades = {
    100: 'A',
    80: 'B',
    60: 'C',
    40: 'D'
  };

  function myFunction() {
    const ele = document.getElementById('mark').value;
    let grade = 'Invalid input';
    for (const g in grades) {
      if (parseInt(ele) < parseInt(g)) {
        grade = grades[g];
        break;
      }
    }
    document.getElementById('grade').value = grade;
  }

It has the flexibility to configure the grades and also handling the invalid cases.

Excel formula: Translate letters to numbers, The Excel VALUE function converts text that appears in a recognized format (i.e. a number, date, or time format) into a numeric value. Normally, the Use the VALUE function to convert text to a numeric value. Excel formula: Assign points based on late time The Excel N function returns a number when given a value. With VLOOKUP, we can use the range values in column D to assign the letter grades in column E to all the actual exam scores. The VLOOKUP Formula. Before we get into applying the formula to our example, let’s have a quick reminder of the VLOOKUP syntax: =VLOOKUP(lookup_value, table_array, col_index_num, range_lookup)

How to use the Excel VALUE function, values = {chr(i): i + 1 for i in range(ord("a"), ord("a") + 26)} If you just want to map characters of the ASCII alphabet to numbers, you can use  This post will guide you how to return a value if a cell contains a certain number or text string in Excel. How do I check if a Cell contains specific text and then return another specific text in another cell with a formula in Excel. Return Value If Cell Contains Certain Value Video: Return read more »

python: How do I assign values to letters?, in two ranges, 427 determining if particular value appears in range, 426 Look 332–333 IF function, 330 introducing, 327–328 for letter grades for test scores, 924–925 adding to Quick Access toolbar, 606–607, 927 assigning to a button,​  Re: Assigning a number value to a letter? Amother approach is to put 10 in a cell, say A1, then pulldown Insert > Name > enter X and touch Add. From that point on you can use X in place of 10 in formulae.

Excel 2016 Bible, Keep the inequality signs going in the same direction: =IF(A1<60, "F", IF(A1<70, "​D", IF(A1<80, "C", IF(A1<90, "B", "A")))). The above works fine as long as there  So let’s say we would like to know the maximum and minimum values within a specific letter grade range. Essentially, what we are looking to do is to filter our data based on a letter grade value in the range of data in column B. Then, with the data filtered, we seek the minimum and maximum values in column A.

Comments
  • Where's your code? What have you tried so far?
  • Thank you so much for the helpful explanation. I have always wondered what these IF conditions are used for, and now I get to make use of it. Thanks again.