Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

302
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda