![]() |
copy to the same workbook
Hello:
When "Copy or Move" sheet, in the dialog there is an opportunity to define a workbook to copy the sheet to. However if I created a macro, it does not reflect my choice, i.e., it comes the same whether I define or not define a workbook. Furthermore, when I run the created macro Sheets("sheet").copy the first time, it places a copy of sheet "sheet" as "sheet (2)" in the same book. However, when run the second time it creates a new workbook without my meaning to. My question: is there a way to specify in the macor the workbook a sheet is to be copied to. Thank you, Alex |
copy to the same workbook
Hello.
You need to specifically state the workbook object that is your destination... like this: Workbooks("Book3").Sheets("Sheet1").Copy After:=Workbooks ("Book2").Sheets(1) the "Book3" would be your workbook's name, or it could be better to use a workbook object to do it. But, it's the "After" parameter that you need to set to do what you're trying to do. |
copy to the same workbook
Mark, thank you.
You see, I do that from inside Java. For me it looks like Sheets sheets = Workbook.getSheets(); Sheet sheet = sheets.getItem("sheet"); sheet.copy(sheet); where the argument sheet in the copy method means "Before", which I presume as suitable as "After" to my ends. So inside the parentheses a sheet is a sheet (that came from a certain workbook.) There is no way for me to specify sheets as an additional argument. I would expect that something like sheet.activate(); would work, but it does not. In fact, I never want a second book, but only the one I start with. Should not there be a default somewhere? Thank you, Alex mark wrote: Hello. You need to specifically state the workbook object that is your destination... like this: Workbooks("Book3").Sheets("Sheet1").Copy After:=Workbooks ("Book2").Sheets(1) the "Book3" would be your workbook's name, or it could be better to use a workbook object to do it. But, it's the "After" parameter that you need to set to do what you're trying to do. |
copy to the same workbook
I haven't used Java to do it... sorry.
-----Original Message----- Mark, thank you. |
All times are GMT +1. The time now is 05:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com