Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default 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.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 196
Default copy to the same workbook

I haven't used Java to do it... sorry.

-----Original Message-----
Mark, thank you.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Excel-how to link source workbook to copy of destination workbook D Lynn Excel Worksheet Functions 1 May 29th 08 05:36 PM
Copy cells based on conditions in one workbook to another workbook fLiPMoD£ Excel Worksheet Functions 0 August 1st 07 07:43 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM


All times are GMT +1. The time now is 07:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"