PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Copy or duplicate excel sheet  (Read 1404 times)

JuanVelazquez

  • Member
  • **
  • Posts: 12
    • View Profile
Copy or duplicate excel sheet
« on: October 28, 2019, 08:51:50 AM »
Good morning

I have an excel book which is composed of several sheets. Currently I have the need to copy or duplicate one of the sheets within the same book but I have not got the form.

The syntax used in VB is:
Worksheets ("Source"). Copy After: = Worksheets ("Final")

Where "Origin" is the sheet to be copied and will be located after the "Final" sheet.

So far I have not been able to properly use the Copy property.

I currently use the object:
DEF OBJECT ex, "excel.application"

Thank you very much for the help you can give me.

Regards

koenv

  • Member
  • **
  • Posts: 12
    • View Profile
Re: Copy or duplicate excel sheet
« Reply #1 on: October 28, 2019, 10:10:58 AM »
->def object excel,"Excel.Application"
->workbook=excel'workbooks'open("filename.xlsx")
->workbook'worksheets("Origin")'copy(*,*workbook'worksheets("Final"))
->excel'visible=1

By default you'll end up with a new worksheet named "Origin (2)".

JuanVelazquez

  • Member
  • **
  • Posts: 12
    • View Profile
Re: Copy or duplicate excel sheet
« Reply #2 on: October 28, 2019, 10:29:25 AM »
->def object excel,"Excel.Application"
->workbook=excel'workbooks'open("filename.xlsx")
->workbook'worksheets("Origin")'copy(*,*workbook'worksheets("Final"))
->excel'visible=1

By default you'll end up with a new worksheet named "Origin (2)".

Hi Koenv

Thanks for the help, it worked perfectly

Regards