Programming advice please
- From: "KC Cheung" <cheun9kc@xxxxxxxxxxxxxx>
- Date: Sat, 31 Dec 2005 20:39:26 +0800
I have a fair bit of information to swap between two workbooks.
>From a utility workbook "Bk-a.xls", I compiled a macro as follow.
Line numbers are added for reference here.
I would appreciate some advice on
why line 70+80 failed (application or obj defined error)
but line 60 is OK
line 90 must be in the form as line 100;
Is there ways to avoid switching windows repeatedly please?
10 Sub t()
20 Dim frmBK As Workbook
30 Dim toBK As Workbook
40 Set frmBK = Workbooks.Open("Bk-b.xls")
50 Set toBK = Workbooks.Open("Bk-c.xls")
60 frmBK.Sheets(1).Range("B1").Copy toBK.Sheets(1).Range("C2")
70 'frmBK.Sheets(1).Range(Range("B1"), Range("B1").End(xlToRight)).Copy _
80 'toBK.Sheets(1).Range("C2")
90 'Windows(frmBK).Activate
100 Windows("bk-b.xls").Activate
110 Range(Range("B1"), Range("B1").End(xlToRight)).Copy
120 'Windows(toBK).Activate
130 Windows("bk-c.xls").Activate
140 Range("C2").PasteSpecial
150 End Sub
Regards
Have a happy New Year
KC
.
- Follow-Ups:
- Re: Programming advice please
- From: KC Cheung
- Re: Programming advice please
- From: Bob Phillips
- Re: Programming advice please
- Prev by Date: Re: Concatenate Non Blank Cells
- Next by Date: Re: Copy cell data from workbook based on user input
- Previous by thread: Re: Concatenate Non Blank Cells
- Next by thread: Re: Programming advice please
- Index(es):