Hi there
I was hoping someone could help me as I'm struggling a bit pls ..
I'm writing a little application that needs to copy certain columns' data from one xls file into another.
I have the below so far:
Say I have sheet1.xls and sheet2.xls (assume each file has only one worksheet).
In sheet1 I would like to copy/select all the data in column D from the 3rd row down until there is no more data and paste this data into sheet2's column A from the 3rd row down (as the 1st 3 rows are headers that should remain as they are.
I'm trying to do the following but it doesn't quite seem to work:
dim xlSourceApp as Excel.Application
dim xlResultApp as Excel.Application
dim xlSourceBook as Excel.Workbook
dim xlResultBook as Excel.Workbook
dim xlSourceSheet as Excel.Worksheet
dim xlSourceSheet as Excel.Worksheet
dim xlResultSheet as Excel.Worksheet
set xlSourceApp = new Excel.Application
set xlResultApp = new Excel.Application
set xlSourceBook = xlSourceApp.Workbooks.Open("c:\sheet1.xls")
set xlResultBook = xlResultApp.Workbooks.Open("c:\sheet2.xls")
set xlSourceSheet = xlSourceBook.sheets(1)
set xlResultSheet = xlResultBook.sheets(1)
xlSourceSheet.columns(3,4).copy
xlResultSheet.columns(3,1).paste
so ... I realise that my problem "probably" lies in the last 2 lines ... any advice would be great cheers!
A
I was hoping someone could help me as I'm struggling a bit pls ..
I'm writing a little application that needs to copy certain columns' data from one xls file into another.
I have the below so far:
Say I have sheet1.xls and sheet2.xls (assume each file has only one worksheet).
In sheet1 I would like to copy/select all the data in column D from the 3rd row down until there is no more data and paste this data into sheet2's column A from the 3rd row down (as the 1st 3 rows are headers that should remain as they are.
I'm trying to do the following but it doesn't quite seem to work:
dim xlSourceApp as Excel.Application
dim xlResultApp as Excel.Application
dim xlSourceBook as Excel.Workbook
dim xlResultBook as Excel.Workbook
dim xlSourceSheet as Excel.Worksheet
dim xlSourceSheet as Excel.Worksheet
dim xlResultSheet as Excel.Worksheet
set xlSourceApp = new Excel.Application
set xlResultApp = new Excel.Application
set xlSourceBook = xlSourceApp.Workbooks.Open("c:\sheet1.xls")
set xlResultBook = xlResultApp.Workbooks.Open("c:\sheet2.xls")
set xlSourceSheet = xlSourceBook.sheets(1)
set xlResultSheet = xlResultBook.sheets(1)
xlSourceSheet.columns(3,4).copy
xlResultSheet.columns(3,1).paste
so ... I realise that my problem "probably" lies in the last 2 lines ... any advice would be great cheers!
A