Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Merge
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Merge
Thanks Joel for your prompt replay but I'm getting object required at
Interspec_HD_Sht.Rows("2:" & Interspec_HD_LastRow).Copy _ Destination:=HDPending_Sht.Rows(Interspec_HD_LastR ow + 1) line can u pls revert on this. TIA "Joel" wrote: 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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Merge
Looking at the code I think I opened the same workbook twice. tTy this change
from Set HDPending = Workbooks.Open( _ Filename:=Folder & "Interspec_HD_EOD_Report.csv") to Set HDPending = Workbooks.Open( _ Filename:=Folder & "HDPending.csv") Make sure you change the line with HDPending. The object wasn't found because excel probably didn't open the workbook because it was already opend. "kiran" wrote: Thanks Joel for your prompt replay but I'm getting object required at Interspec_HD_Sht.Rows("2:" & Interspec_HD_LastRow).Copy _ Destination:=HDPending_Sht.Rows(Interspec_HD_LastR ow + 1) line can u pls revert on this. TIA "Joel" wrote: 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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Merge
Thanks Joel
"Joel" wrote: Looking at the code I think I opened the same workbook twice. tTy this change from Set HDPending = Workbooks.Open( _ Filename:=Folder & "Interspec_HD_EOD_Report.csv") to Set HDPending = Workbooks.Open( _ Filename:=Folder & "HDPending.csv") Make sure you change the line with HDPending. The object wasn't found because excel probably didn't open the workbook because it was already opend. "kiran" wrote: Thanks Joel for your prompt replay but I'm getting object required at Interspec_HD_Sht.Rows("2:" & Interspec_HD_LastRow).Copy _ Destination:=HDPending_Sht.Rows(Interspec_HD_LastR ow + 1) line can u pls revert on this. TIA "Joel" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
merge two excel files like in word mail merge | Excel Discussion (Misc queries) | |||
Mail merge macro: select recipients from Excel during merge | Excel Programming | |||
Trying to merge from excel to word. New names won't merge | Excel Worksheet Functions | |||
mail merge excludes my headers and critical data in Word merge | Excel Discussion (Misc queries) | |||
Can I merge an excel list to an excel sheet like mail merge in wor | Excel Programming |