D
D
delongeroman2020-08-19 22:14:56
Google Apps Script
delongeroman, 2020-08-19 22:14:56

How to do automatic sorting in Google Sheets?

5f3d79607d136872328155.png
In my table, the entry form is at the top, and at the bottom is what a person fills out in this form. Now I have sorting through the "on change" trigger and it doesn't work very well. How can I make it so that when I enter a new order, sorting is enabled for me?

function sort(){
  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var as2 = ss.getSheetByName("02") //лист 2
  
  var editedCell = ss.getActiveRange().getValue();
  var cell2 = as2.getRange("B7:B").getValues()

  if(editedCell!=cell2  ){ //лист 2
  as2.getRange('A7:P').sort([{column: 2, ascending: true}]); 
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
delongeroman, 2020-08-20
@delongeroman

Issue resolved
var ss = SpreadsheetApp.getActiveSpreadsheet();- replace with

var ss = SpreadsheetApp.openById( "тут ваш id таблицы");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question