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

291
Visualizações
Excel JavaScript - VBA How to copy values from a range to another sheet?

I want to copy values from one range to another sheet (in the same workbook) using Excel JavaScript, that is, taking some range values and pass them to another sheet.

The Excel Javascript API shows how to copy one range to another range in the same worksheet:

    let sheet = context.workbook.worksheets.getItem("Sample");
    // Copy everything from "A1:E1" into "G1" and the cells afterwards ("G1:K1").
    sheet.getRange("G1").copyFrom("A1:E1");
    await context.sync();
});

However I can't achieve to do it in another worksheet (of the same workbook).

This is the code that I'm using but it shows me some errors about using wrong parameters in the methods.

  await Excel.run(async (context) => {
    const captura = context.workbook.worksheets.getItem("Captura");
    const historico = context.workbook.worksheets.getItem("Historico");

    var rango = captura.getRange("A3:F5");

    var i = historico.getUsedRange().getLastRow();


    historico.getRange("A" + i).copyFrom(rango);

    await context.sync();
  });
}
about 4 years ago · Juan Pablo Isaza
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