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

295
Vistas
How to loop through each column in a given row and then have the loop go automatically to the next column

I need to extract a data from this other sheet where the header will repeat itself by the number of items under it. So far I can only do this with the first column from the data source and I can’t seem to get the right code where the loop will go through the next column once it detects the first empty cell of the previous column.

Here’s where I am getting stuck

function filter(){

var sheet = SpreadsheetApp.getActiveSpreadsheet()
var data = sheet.getSheetByName("data")
var filter = sheet.getSheetByName("filter")

var dataRange = data.getDataRange().getValues();
var dataLr = data.getLastRow();
var dataLc = data.getLastColumn();

var row = 1
var col = 1

 for(var i=1; i < dataRange.length; i++){
  let targetAppName = filter.getRange(i+1,1)
  let targetQname = filter.getRange(i+1,2)

        targetQname.setValue(dataRange[i])
        targetAppName.setValue(dataRange[0][0])

}
}

I’m trying to get these results in another sheet tab:

|Names | Subjects | |:—————|:———————-:|

|Michael Lowry| Trigonometry|

|Michael Lowry| Biology|

And so on, until it reads all columns and rows of the data range

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

0

Loop throught each column of each row

function loopthroughteachcolumnofarow() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getActiveSheet();
  const vs = sh.getDataRange().getValues();
  vs.forEach((r,i) => {
    r.forEach((c,j) => {
      //c is the value for vs[i][j];
    })
  })
}
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