Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Copy and Paste Between Files
Hi,
I have two excel files that are generated by an application. I have created a third excel file that contains some macros/code. I am using these macros to open these files one at a time and clean up some of the headers etc and delete some columns. My goal is to take rows from one sheet and paste them into the other sheet at a cetain location. In the following example, I need to take IT people from File1 and paste them into File2 -BEFORE- S.Smith in IT and after AC department. Same way, I need to copy all HR people from File1 and paste them into File2 Before Q. Johnson in HR and After IT people. I have been able to find correct rows and use the 'cut' command but paste is not available when I switch to File 2. Any ideas? Also, when I try to close either of the files I am getting Error 400 or something similar. Thank you.. Example: File 1 Name Dept. Location J. Smith IT CA K. Jones IT NY S. Moor HR CA P. Johnson HR CA P. Smith HR CA File 2 Name Dept. Location K. Jones AC NY S. Smith IT CA W. Smith IT CA Q. Johnson HR CA R. Smith HR CA Result should be: File 2 Name Dept. Location K. Jones AC NY J. Smith IT CA K. Jones IT NY S. Smith IT CA W. Smith IT CA S. Moor HR CA P. Johnson HR CA P. Smith HR CA Q. Johnson HR CA R. Smith HR CA |
#2
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
|
|||
|
|||
Copy and Paste Between Files
As long as you know the logic of which rows to cut/copy and where to paste:
Dim WB1 As Workbook Dim WB2 As Workbook Set WB1 = Workbooks.Open("C:\File1.xls") Set WB2 = Workbooks.Open("C:\File2.xls") WB1.Worksheets(1).Range("A6:C6").Cut 'or Copy ? WB2.Worksheets(1).Range("A6").Insert Shift:=xlDown 'Correct direction ? WB1.Close False 'Or True ? WB2.Close False 'Or True ? By the way, why not just add to the end of the list and then Sort as required ? (Although ACITHR is not listed alphabetically) NickHK "Dragon" wrote in message ... Hi, I have two excel files that are generated by an application. I have created a third excel file that contains some macros/code. I am using these macros to open these files one at a time and clean up some of the headers etc and delete some columns. My goal is to take rows from one sheet and paste them into the other sheet at a cetain location. In the following example, I need to take IT people from File1 and paste them into File2 -BEFORE- S.Smith in IT and after AC department. Same way, I need to copy all HR people from File1 and paste them into File2 Before Q. Johnson in HR and After IT people. I have been able to find correct rows and use the 'cut' command but paste is not available when I switch to File 2. Any ideas? Also, when I try to close either of the files I am getting Error 400 or something similar. Thank you.. Example: File 1 Name Dept. Location J. Smith IT CA K. Jones IT NY S. Moor HR CA P. Johnson HR CA P. Smith HR CA File 2 Name Dept. Location K. Jones AC NY S. Smith IT CA W. Smith IT CA Q. Johnson HR CA R. Smith HR CA Result should be: File 2 Name Dept. Location K. Jones AC NY J. Smith IT CA K. Jones IT NY S. Smith IT CA W. Smith IT CA S. Moor HR CA P. Johnson HR CA P. Smith HR CA Q. Johnson HR CA R. Smith HR CA |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can't Copy and Paste or Paste Special between Excel Workbooks | Excel Discussion (Misc queries) | |||
Copy / Paste Warning | Excel Discussion (Misc queries) | |||
copy & paste, a NEW CONCEPT (from Outlook to... Excel) | Excel Discussion (Misc queries) | |||
Macro to open workbook and copy and paste values in to orig workbo | Excel Worksheet Functions | |||
Can't Copy and Paste between Excel 2003 Workbooks | Excel Discussion (Misc queries) |