![]() |
#1
|
|||
|
|||
![]()
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 |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
jonpackbosoxfan | Excel | 34 | 09-18-2013 08:38 AM |
![]() |
jmhultin | Outlook | 2 | 08-09-2013 02:01 PM |
Merge Excel files | Balas | Excel | 4 | 07-02-2012 06:09 AM |
![]() |
Kaloyanski | Excel | 3 | 11-02-2011 02:47 AM |