How to copy a worksheet from one workbook to another in vb6
Subscript out of range will mean that either you don't have an open workbook
with the name in the strFile variable -- or the strFinalReport variable.
Or you don't have a "Summary" sheet in that first workbook--or you don't have
"Sheet1" in the strFinalReport workbook.
SpiderSwamy wrote:
Hi Sorry man..
real code is like this where strFile = 2.xls and strFinalReport = 1.xls
Workbooks(strFile).Worksheets("summary").Copy _
After:=Workbooks(strFinalReport).Worksheets("sheet 1")
thanks
Swamy
wrote:
try... with quotes in the workbooks object....
Workbooks("2.xls").Worksheets("sheet2").Copy _
After:=Workbooks("1.xls").Worksheets("sheet1")
SpiderSwamy wrote:
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.
--
Dave Peterson
|