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

206
Vistas
How do I copy only the visible rows from one tab to another in Google Sheets?

I have an input tab with 13 columns of data. I used the filter from Google Sheets to restrain the data and I want only the filtered data to be put in an output tab.

I tried using this Google Apps Script code for that, however it does not work as intended.

function showResults() {
  var sheet = SpreadsheetApp.getActiveSheet();  
  var data = [];

  for (var i = 1; i < sheet.getLastRow(); i++) {
    if(!sheet.isRowHiddenByFilter(i)) {
      var row_data = sheet.getRange("A" + i + ":M" + i).getValues();
      console.log(row_data);
      data.push(row_data);
    }
  }
  
  sheet.getRange('Results!A1:M' + (data.length + 1)).setValues(data);
}

The problem I noticed in the logs is that it only goes through the first row of the filtered data before exceeding the maximum execution time.

Any help is appreciated, especially if it's a Google Sheets feature I didn't know about and not necessarily the code.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Hi you must clone your sheet and use cloned object for fix your problem like this :

function showResults() {
  var sheet = SpreadsheetApp.getActiveSheet();  
  var data = [];

  for (var i = 1; i < sheet.getLastRow(); i++) {
     let cache = JSON.parse(JSON.stringify(sheet ))
    if(!sheet.isRowHiddenByFilter(i)) {
      var row_data = cache.getRange("A" + i + ":M" + i).getValues();
      console.log(row_data);
      data.push(row_data);
    }
  }
  
  sheet.getRange('Results!A1:M' + (data.length + 1)).setValues(data);
}
about 4 years 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 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