0
votes

I'm looking to set up a =QUERY statement that will automatically sort my all column data. I have tried copying and pasting several bits of code but cannot get this to work. Within the spreadsheet I'm working in, I am pulling data from several different sheets so I'm hoping the solution could work with the pre-existing formulas.

The link below is to a test sheet which should give an idea as to how I have formatted my sheet: https://docs.google.com/spreadsheets/d/1DpvubqE63soHvHJoMMlovRa99Lf0k1upJ3z5ji_3Dd0/edit#gid=1993834648

I'm working out of the "Unsorted Pre-Review Hashtag Counter" sheet where I'm looking to have all data in A11:F34 auto-sort in descending order using the total number of interactions in Column F.

Been looking around for a solution to this for a while and not finding anything that works, unfortunately. Any suggestions welcome!

Thank you in advance for your help.

1

1 Answers

0
votes

I understand that you want a way to autosort the table using a container-bound App Script. If that is the case, you should use the following function. It will run every time that you edit the spreadsheet using a onEdit simple trigger, and will use sort on your table as you requested.

function onEdit() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getSheets()[2];
  var range = sheet.getRange("A11:F34");
  range.sort({column: 6, ascending: false});
}

Please, don't hesitate to ask for more clarification if you need further help.