Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-10-2015, 06:09 AM
Sandhya Sandhya is offline Merge the data from different excel files. Windows 7 32bit Merge the data from different excel files. Office 2007
Novice
Merge the data from different excel files.
 
Join Date: Nov 2014
Posts: 21
Sandhya is on a distinguished road
Smile Merge the data from different excel files.

Hi Friends,

Kindly rectify the error in the below code.
it will consolidate the diffrerent excel file data into one single file.

error is getting into the below row.
______________________________

"ActiveSheet.Paste Destination = Worksheets("Sheet1"), Range(Cells(erow, 1), Cells(erow, 4))"

____________________

Sub copyDataFromMultipleWorkbooksintoMaster()
Dim FolderPath As String, filepath As String, filename As String
FolderPath = "c:\CONSOLIDATE\"
filepath = FolderPath & "*.xls*"
filename = Dir(filepath)
Dim lastrow As Long, lastcolumn As Long
Do While filename <> ""
Workbooks.Open (FolderPath & filename)


lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
lastcolumn = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Range(Cells(2, 1), Cells(lastrow, lastcolumn)).Copy
Application.DisplayAlerts = False
ActiveWorkbook.Close
erow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination = Worksheets("Sheet1"), Range(Cells(erow, 1), Cells(erow, 4))

filename = Dir
Loop
Application.DisplayAlerts = True


End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Merge the data from different excel files. Merge data from excel into word jonpackbosoxfan Excel 34 09-18-2013 08:38 AM
Merge the data from different excel files. Merge data files jmhultin Outlook 2 08-09-2013 02:01 PM
Merge Excel files Balas Excel 4 07-02-2012 06:09 AM
Merge the data from different excel files. How can I merge different excel files into one? Kaloyanski Excel 3 11-02-2011 02:47 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft