Gary_Mc_Mahon
Board Regular
- Joined
- Apr 30, 2003
- Messages
- 87
Hi,
I'm trying to write a macro to open a bunch of csv files and copy them into a designated place in an excel workbook. When I go to close the source data (in this case the csv file) I'm prompted with the "there is a large amount of data on the clipboard........" message. I've tried to use enable events = false but this doesnt seem to work. Has it got something to do witht the source data being a csv file?? Any tips welcome.
Sub Merge_Data()
Workbooks("TEMPLATE Weekly Billing Slide.xls").Activate
'--- Copy qry_1 to template ------
Sheets("Qry_1").Activate
Cells.Select
Selection.ClearContents
Workbooks.Open "R:\UK - Sales\.....UK data\tbl_1.csv"
Sheets(1).Activate
Cells.Select
Selection.Copy
Workbooks("TEMPLATE Weekly Billing Slide.xls").Activate
Sheets("Qry_1").Activate
Range("A1").Select
ActiveSheet.Paste
CutCopyMode = False
Workbooks("tbl_1.csv").Activate
Application.EnableEvents = False
Workbooks("tbl_1.csv").Close Savechanges:=False
Application.EnableEvents = True
End Sub
Thanks
Gary
I'm trying to write a macro to open a bunch of csv files and copy them into a designated place in an excel workbook. When I go to close the source data (in this case the csv file) I'm prompted with the "there is a large amount of data on the clipboard........" message. I've tried to use enable events = false but this doesnt seem to work. Has it got something to do witht the source data being a csv file?? Any tips welcome.
Sub Merge_Data()
Workbooks("TEMPLATE Weekly Billing Slide.xls").Activate
'--- Copy qry_1 to template ------
Sheets("Qry_1").Activate
Cells.Select
Selection.ClearContents
Workbooks.Open "R:\UK - Sales\.....UK data\tbl_1.csv"
Sheets(1).Activate
Cells.Select
Selection.Copy
Workbooks("TEMPLATE Weekly Billing Slide.xls").Activate
Sheets("Qry_1").Activate
Range("A1").Select
ActiveSheet.Paste
CutCopyMode = False
Workbooks("tbl_1.csv").Activate
Application.EnableEvents = False
Workbooks("tbl_1.csv").Close Savechanges:=False
Application.EnableEvents = True
End Sub
Thanks
Gary