Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
script help, i am new to coding

hello i am new to coding , this is a google sheet app script problem that i have, so, i have 2 sheet and i want to sort in order both of them, sort different column , ive succeded in making the code work for both of them but my issue is that it will only work for 1 of them, seem like the function im creating only work for the 1st function ive enter, the second below dont work, but will work individualy, what im trying to do is to create 1 function that work for both of my sheet, anyone know ?

SHEET_NAME = "The Convenant { Member Roster )";
SORT_DATA_RANGE = "B5:J1187";
SORT_ORDER = [
{column: 5, ascending: true},  // 5 = column number, sorting by descending order
{column: 4, ascending: true}, // 1 = column number, sort by ascending order
];

function onEdit(e){
  multiSortColumns();
}
function multiSortColumns(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(SHEET_NAME);
  var range = sheet.getRange(SORT_DATA_RANGE);
  range.sort(SORT_ORDER);
  ss.toast('Sort complete.');
}
SHEET_NAME = "The Convenant ( War Roster )";
SORT_DATA_RANGE = "B5:I1086";
SORT_ORDER = [
{column: 3, ascending: true},  // 3 = column number, sorting by descending order
{column: 2, ascending: true}, // 1 = column number, sort by ascending order
];

function onEdit(e){
  multiSortColumns();
}
function multiSortColumns(){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(SHEET_NAME);
  var range = sheet.getRange(SORT_DATA_RANGE);
  range.sort(SORT_ORDER);
  ss.toast('Sort complete.');
}

enter image description here

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can't duplicate twice the same function, for instance onEdit and multisortcolumns. Try

function onEdit(e){
  multiSortColumns();
}
function multiSortColumns(){
SHEET_NAME = "The Convenant { Member Roster )";
SORT_DATA_RANGE = "B5:J1187";
SORT_ORDER = [
{column: 5, ascending: true},  // 5 = column number, sorting by descending order
{column: 4, ascending: true}, // 1 = column number, sort by ascending order
];
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(SHEET_NAME);
  var range = sheet.getRange(SORT_DATA_RANGE);
  range.sort(SORT_ORDER);
  ss.toast('Sort complete.');

SHEET_NAME = "The Convenant ( War Roster )";
SORT_DATA_RANGE = "B5:I1086";
SORT_ORDER = [
{column: 3, ascending: true},  // 3 = column number, sorting by descending order
{column: 2, ascending: true}, // 1 = column number, sort by ascending order
];
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(SHEET_NAME);
  var range = sheet.getRange(SORT_DATA_RANGE);
  range.sort(SORT_ORDER);
  ss.toast('Sort complete.');
}

but may be yoy can test on which tab the onedit function is relative

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda