Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Copy and Paste or Paste Special between Excel Workbooks wllee Excel Discussion (Misc queries) 5 April 29th 23 03:43 AM
Copy / Paste Warning wbmcse Excel Discussion (Misc queries) 0 March 3rd 06 07:04 PM
copy & paste, a NEW CONCEPT (from Outlook to... Excel) Brainless_in_Boston Excel Discussion (Misc queries) 1 February 24th 06 05:39 PM
Macro to open workbook and copy and paste values in to orig workbo Dena X Excel Worksheet Functions 1 December 15th 05 11:13 PM
Can't Copy and Paste between Excel 2003 Workbooks wllee Excel Discussion (Misc queries) 6 March 30th 05 02:59 PM


All times are GMT +1. The time now is 02:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"