How to copy a worksheet from one workbook to another in vb6

S

SpiderSwamy

Hi All,

I have 2 workbook(i.e. 1.xls & 2.xls) at 2 different location, I want
to copy all the worksheets present in 2.xls to 1.xls file using vb6.

I am trying to open both the files and then trying with this code...

Workbooks("2.xls").Worksheets("sheet2").Copy _
After:=Workbooks("1.xls").Worksheets("sheet1")

I am getting "subscript out of range" error.... can u plz help me...

Thanks in Advance.
 
G

Graham Mayor

You might do better in a visual basic - or at least an Excel group. This one
is for Word.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

Jean-Yves

Hi Spider
Wrong newsgroup
Try : microsoft.public.excel.programming

Workbooks("2.xls").activate
Worksheets("sheet2").Copy After:=Workbooks("1.xls").Worksheets("sheet1")
Be sure that all workbook name or sheet are correct
Regards
Jean-Yves
 
S

SpiderSwamy

Hi Thanks.
I will do that ..
:)

Regards
Spider

Jean-Yves said:
Hi Spider
Wrong newsgroup
Try : microsoft.public.excel.programming

Workbooks("2.xls").activate
Worksheets("sheet2").Copy After:=Workbooks("1.xls").Worksheets("sheet1")
Be sure that all workbook name or sheet are correct
Regards
Jean-Yves
 

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