title: How to capitalize all sheet except specific columns on Google spreadsheet using Google Script?
body: <p>This code capitalize all the sheet cells, except some columns as required. Nevertheless, formulas into the excluded cells are deleted.
  I do not want the script erase my formulas into these columns.</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>function onOpen() {
      var ui = SpreadsheetApp.getUi();
      ui.createMenu('Eta Buddy')
          .addItem('Capitalize', 'proper')
          .addToUi();
  }
  
  
  function proper() {
  var s = SpreadsheetApp.getActiveSheet(),
  excludedCols = [2, 4, 6, 8, 10];
  s.getDataRange()
      .setValues(
          s.getDataRange()
          .getValues()
          .map(function (r) {
              return r.map(function (el, i) {
                 return !el ? null : (typeof el !== 'string' &amp;&amp; el) || excludedCols.indexOf(i + 1) &gt; -1 ? el : toTitleCase(el);
              })
          })
      )
  }
  
  function toTitleCase(str) {
      return str.replace(/\w\S*/g, function (txt) {
          return txt.charAt(0)
              .toUpperCase() + txt.substr(1)
              .toLowerCase();
      });
  }</code></pre>
  </div>
  </div>
  </p>