title: Assigning values based on cells in a column google scripts
body: <p>I have written the following script to insert certain values in a column based on values in another column.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> for (i = 1; i &lt; sh.getLastRow(); i++) {
      if (vA[i][21]=="SP") {sh.getRange(i+1,24,1,1).setValue('01')}
          else if (vA[i][21]=="MCD") {sh.getRange(i+1,24,1,1).setValue('02')} 
          else if (vA[i][21]=="MCR") {sh.getRange(i+1,24,1,1).setValue('03')}
          else {sh.getRange(i+1,24,1,1).setValue('99')
          };</code></pre>
  </div>
  </div>
  
  Basically I want to write &quot;01&quot; for &quot;SP&quot;, &quot;02&quot; for &quot;MCD&quot; and &quot;03&quot; for &quot;MCR&quot;, etc...</p>
  <p>This script works ok but the process is too time-consuming when I have a few hundred rows to process. Is there any alternative? Thank you for your time.</p>