Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

289
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!