Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copying worksheet to another workbook | Excel Worksheet Functions | |||
Copying Worksheet to new workbook with VBA | Excel Programming | |||
Copying a worksheet into the same workbook | New Users to Excel | |||
Copying A Worksheet From Each Open Workbook to an new Workbook | Excel Worksheet Functions | |||
Copying worksheet to another workbook | Excel Programming |