Excel Merge
Make copies of all files before trying this code.
Sub Copyfiles()
Folder = "C:\Temp\"
Set HDPending = Workbooks.Open( _
Filename:=Folder & "Interspec_HD_EOD_Report.csv")
Set HDPending_Sht = HDPending.Sheets(1)
HDPending_LastRow = HDPending_Sht.Range("A" & Rows.Count).End(xlUp).Row
Set Interspec_HD = Workbooks.Open( _
Filename:=Folder & "Interspec_HD_EOD_Report.csv")
Set Interspec_HD_Sht = Interspec_HD.Sheets(1)
Interspec_HD_LastRow = Interspec_HD_Sht.Range("A" & Rows.Count).End(xlUp).Row
Interspec_HD_Sht.Rows("2:" & Interspec_HD_LastRow).Copy _
Destination:=HDPending_Sht.Rows(Interspec_HD_LastR ow + 1)
HDPending.Close Savechanges:=False
Interspec_HD.Close Savechanges:=True
Set HDPending = Nothing
Set HDPending_Sht = Nothing
Set Interspec_HD = Nothing
Set Interspec_HD_Sht = Nothing
Set CHReport = Workbooks.Open( _
Filename:=Folder & "CHReport.csv")
Set CHReport_Sht = CHReport.Sheets(1)
CHReport_LastRow = CHReport_Sht.Range("A" & Rows.Count).End(xlUp).Row
Set Interspec_CH = Workbooks.Open( _
Filename:=Folder & "Interspec_CH_EOD_Report.csv")
Set Interspec_CH_Sht = Interspec_CH.Sheets(1)
Interspec_CH_LastRow = Interspec_CH_Sht.Range("A" & Rows.Count).End(xlUp).Row
Interspec_CH_Sht.Rows("2:" & Interspec_CH_LastRow).Copy _
Destination:=CHReport_Sht.Rows(Interspec_CH_LastRo w + 1)
CHReport.Close Savechanges:=False
Interspec_CH.Close Savechanges:=True
End Sub
"kiran" wrote:
Hi All,
I have 4 csv report file with the following file name as follows :-
Interspec_CH_EOD_Report.csv
CHReport.csv
Interspec_HD_EOD_Report.csv
HDPending.csv
my query is I want all HDPending.csv data to be copied in
Interspec_HD_EOD_Report.csv file at the end of the row of
Interspec_HD_EOD_Report.csv file deleting the heading row from HDPending.csv
like for CHReport.csv also to be copied
to Interspec_CH_EOD_Report.csv file.
TIA
|