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

135
Visualizações
For Loop in Google Macro

I'm trying to run a macro loop that copies and input, pastes it into another cell on the same sheet and then pastes the output into a cell directly next to the input. I would like the loop to continue for 135ish rows with inputs and outputs just continually getting copied and pasted. Below is what I have so far, but when I try to run it all I get is "spreadsheet.getRange is not a function"

Update: Ive added (). to the first line and now I get a "Range not found" error

function SameSheet() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet;
  for(var i = 1; i <= 132; i++ ) {
    var Team = spreadsheet.getRange(i, 1).getValue();
    var Output = spreadsheet.getRange ( i, 2)
    spreadsheet.getRange('F1').activate();
    spreadsheet.getRange(Team).copyTo(spreadsheet.getActiveRange(), 
    SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
    spreadsheet.getRange(Output).activate();
    spreadsheet.getRange('H36:J36').copyTo(spreadsheet.getActiveRange(), 
    SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);

  }};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

function SameSheet() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getActiveSheet;
  const vs = sh.getRange(1, 1, 132).getValues().forEach((r, i) => {
    let team = r[0];//getting same value from array is much faster
    let output = r[1];//same here
    sh.getRange(team).copyTo(sh.getRange('F1'), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
    sh.getRange('H36:J36').copyTo(sh.getRange(output), SpreadsheetApp.CopyPasteType.PASTE_VALUES, false);
  });
}
about 4 years ago · Juan Pablo Isaza 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