Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Copying Worksheet from one workbook to another

I have the following bit of code

Set newWS =
myWS.Copy(After:=CombinedWB.Sheet(CombinedWB.Works heets.Count))

newWS and myWS are worksheets and CombinedWB is a workbook.

I'm getting a compile error (Expected Function or Variable) on COPY. What
am I missing? I've done this before and can't find the example.

Thanks,

Barb Reinhardt

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Copying Worksheet from one workbook to another

Copy does not return the new worksheet that it creates (unlike the add
method) so you can not set your worksheet reference to it. So for example
this works

Dim wks As Worksheet

Sheet1.Copy After:=Sheet3
Set wks = ActiveSheet

In your case it is going to be a tad bit more complicated. You can use the
index number of the sheet though to set your worksheet object. Untested but
this might do it...

myWS.Copy(After:=CombinedWB.Sheet(CombinedWB.Works heets.Count))
Set newWS = CombinedWB.Sheet(CombinedWB.Worksheets.Count)

--
HTH...

Jim Thomlinson


"Barb Reinhardt" wrote:

I have the following bit of code

Set newWS =
myWS.Copy(After:=CombinedWB.Sheet(CombinedWB.Works heets.Count))

newWS and myWS are worksheets and CombinedWB is a workbook.

I'm getting a compile error (Expected Function or Variable) on COPY. What
am I missing? I've done this before and can't find the example.

Thanks,

Barb Reinhardt

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
Copying worksheet to another workbook Dig Excel Worksheet Functions 3 October 30th 08 09:01 PM
Copying Worksheet to new workbook with VBA Barb Reinhardt Excel Programming 1 July 3rd 08 07:11 PM
Copying a worksheet into the same workbook Michael New Users to Excel 9 February 6th 06 08:35 PM
Copying A Worksheet From Each Open Workbook to an new Workbook carl Excel Worksheet Functions 1 January 3rd 06 05:37 PM
Copying worksheet to another workbook Haider Quazilbash Excel Programming 2 September 22nd 03 06:23 PM


All times are GMT +1. The time now is 07:21 AM.

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

About Us

"It's about Microsoft Excel"