Macro Error

V

Vick

I keep receiving this error and I can't figure out what i've done wrong, any
help would be appreciated. Thanks

Workbooks.Open Filename:="C:\Temp\Mgmt Team Stmt legacy.xls"
Windows("Mgmt Team Stmt legacy.xls").Activate
Sheets("Cover Sht").Select
Sheets("Cover Sht").Copy Before:=Workbooks("Book1").Sheets(1)

All I'm trying to do is copy a worksheet from a workbook, to another workbook.

The last line is the line that continues to error out.
 
D

Dave Peterson

I'd try including the .xls extension:
Sheets("Cover Sht").Copy Before:=Workbooks("Book1.xls").Sheets(1)

Or maybe...

dim wks as worksheet
set wks = Workbooks.Open(Filename:="C:\Temp\Mgmt Team Stmt legacy.xls") _
.worksheets("cover sht")
wks.copy _
Before:=Workbooks("Book1.xls").Sheets(1)

'maybe???
wks.parent.close savechanges:=false
 
F

FSt1

hi
your last line of code doesn't make sense. Before is a keyword used when
adding a sheet. is that what your are trying to do? add a sheet to book 1.
you need to activate book 1 or add book 1 first.

post back with more info on what your are doing.
regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top