Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Read Multiple excel files and save data in single excel sheet
#3
Solved: 11 Years, 3 Months, 3 Weeks ago
Hi Mahesh,
Please find the below code,
Here i wrote the code for appending two excel sheets data in to third excel sheets.
Code:
msgbox "Going to Start"
Set objExcel = CreateObject("Excel.Application")
'objExcel.Visible = True
Set objWorkbook1= objExcel.Workbooks.Open("C:\Documents and Settings\Venkat.Batchu\Desktop\d1.xls")
Set objWorkbook2= objExcel.Workbooks.Open("C:\Documents and Settings\Venkat.Batchu\Desktop\d2.xls")
Set objWorkbook3= objExcel.Workbooks.Open("C:\Documents and Settings\Venkat.Batchu\Desktop\d12.xls")
st="A1"
objWorkbook1.Worksheets("Sheet1").UsedRange.Copy
objWorkbook3.Worksheets("Sheet1").Range(st).PasteSpecial Paste =xlValues
objWorkbook1.save
objWorkbook3.save
objWorkbook1.close
'objWorkbook3.close
rcount=objWorkbook3.Worksheets("Sheet1").UsedRange.rows.count
rcount=rcount+1
st="A"&rcount
objWorkbook2.Worksheets("Sheet1").UsedRange.Copy
objWorkbook3.Worksheets("Sheet1").Range(st).PasteSpecial Paste =xlValues
objWorkbook2.save
objWorkbook3.save
objWorkbook2.close
objWorkbook3.close
set objExcel=nothing
msgbox "Done"

Steps perfomed in the above code:
1.First i have copied the file d1 and paste in to d12
2.Find the number of rows in d12 (Ex;10 rows)
3.Copied the file d2 and appended to d12 (appended to previous data i.e d1 here data is appended from 11th row)
4.Finally we have d12 file with d1 and d2

If you want to perform with number of sheets then use for loop or use function using above code

Regards,
Venkat.Batchu


Messages In This Thread
RE: How to Read Multiple excel files and save data in single excel sheet - by venkatbatchu - 12-02-2009, 11:39 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Convert the single to an integer Mozza 2 1,408 09-27-2018, 12:36 PM
Last Post: Ankur
  Comparing two unsorted excel columns ProTester 2 2,790 09-13-2018, 02:11 PM
Last Post: ProTester
  export UFT datasheet to excel and then append Mozza 0 1,893 09-04-2018, 08:58 AM
Last Post: Mozza
  how can i click a macro button in excel using vbscript arpan 1 3,743 10-03-2017, 06:27 AM
Last Post: supputuri
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,707 01-17-2017, 11:05 AM
Last Post: JACKSPARROW

Forum Jump:


Users browsing this thread: 2 Guest(s)