Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Failure to autsort Google Sheets

$
0
0

I have a Google sheets that has the responses from a Google Form. I want the responses to be sorted according to contents of three columns (9, 12 and 13) when the sheet is opened. I'm using this script, but it is failing. Can anyone suggest why?

function autoSort(sheet) {  var NUMBER_OF_HEADER_ROWS = 1;  var range = sheet.getDataRange();  if (NUMBER_OF_HEADER_ROWS > 0) {    range = range.offset(NUMBER_OF_HEADER_ROWS, 0);  }  range.sort([{column: 8, ascending: true}, {column: 11, ascending: true}, {column: 12, ascending: true}]);//  range.sort( {//   column: SORT_COLUMN_INDEX,//    ascending: ASCENDING//  } );}// function onOpen(event) {//  var sheet = SpreadsheetApp.getActive().getSheetByName("Form Responses 1");// autoSort(event.source);//  }function onOpen(e) {  var sheet = e.source.getActiveSheet(); // get the default sheet when the spreadsheet opens  autoSort(sheet);}

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>