• Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Precios
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

68
Vistas
Google sheets Script - Sort sheet by column AP under category headers (colored background)

I am fairly new to Javascript/Apps Script.

I have a sheet that contains a few categories and their data on a single sheet. I am trying to create a script that sorts whats under each category (header) by column AP.

Currently we are manually selecting the range then running the following macro to sort by the column.

function SortAP() {
  var spreadsheet = SpreadsheetApp.getActive();
  spreadsheet.getActiveRange()
  .sort({column: 42, ascending: true});
};

I want to have this query a row for a header and then run the function. Is this possible?

Here is an example sheet of what our headers look like

9 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Sort Each Column

function sortEachColumn() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName('Sheet1');//Edit sheet name as necessary
  const sr = 2;//data start row
  [...Array.from(new Array(sh.getLastColumn()).keys(),x => sh.getRange(2,x+1,sh.getLastRow()).sort({column:x + 1,ascending:true}))];
}

enter image description here

Array.from()

9 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar empleo Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2023 PeakU Inc. All Rights Reserved.