Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

31
Views
Copy worksheet to same workbook and rename it using Javascript

I am trying to write a function where a specified workbook is opened and then we need to copy existing sheet and make a copy of it in the same workbook and rename that worksheet. I saw this feature is implemented In VBA using the code below.

Worksheets("Sheet1").Copy After:=Worksheets("Sheet3")

In Javascript I am trying to do

  var xlApp = new ActiveXObject("Excel.Application");
  var xlWorkbooks = xlApp.Workbooks;
  var xlWorkbook = xlWorkbooks.Open(xlFileName);
  var xlWorksheets = xlWorkbook.Worksheets;
  var xlWorkSheet = xlObj.getWorksheet("PRC1.1");
  xlWorkSheet.copy();

This code is creating a copy in new workbook but I want in the same workbook.

Any Answers would be highly appreciated. Thanks in Advance.

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs