by Cary Sampson This is my issue:
At work we currently use google sheets for orders that go on hold. My issue is that I want all new entries to show up top. I've searched throughout the forum and found solutions but for some reason it will not work for me. I can't post my spreadsheet due to business guidelines. I created a "sister sheet" and pasted the scripts that I came across into field A1. At first it said invalid sheet name. So i renamed it from Form Responses to Q4 2014. After that it gave me an error "Parse error" Tried researching it on my own to figure it out but to no avail. Cell A1 is named Timestamp. I need to sorted automatically with each scan to show up top instead of bottom.
Thank you for your time.
The code is written by: --Hyde - Top Contributor - Member since 9/17/12
var sheetToSort = "Form Responses 1"; // replace this with "Form Responses" or whichever sheet you want to sort automatically
var columnToSortBy = 1; // column A = 1, B = 2, etc.
var rangeToSort = "A2:B1100";
function onEdit() {
var sheet = SpreadsheetApp.getActiveSheet();
var editedCell = sheet.getActiveCell();
if (editedCell.getColumn() == columnToSortBy && sheet.getName() == sheetToSort) {
sortFormResponsesSheet();
}
}
function sortFormResponsesSheet() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetToSort);
var range = sheet.getRange(rangeToSort);
range.sort( { column : columnToSortBy, ascending: false } );
}