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
use macros to copy and paste from 1 file to several files Joy Excel Worksheet Functions 0 March 5th 08 07:08 AM
Macro 4 copy & paste between 2 books/files FARAZ QURESHI Excel Discussion (Misc queries) 1 October 7th 07 06:41 PM
Copy and Paste Between Files Dragon Excel Discussion (Misc queries) 1 February 5th 07 04:26 AM
Copy and Paste ranges between files dude Excel Programming 3 July 23rd 03 01:37 PM


All times are GMT +1. The time now is 11:24 AM.

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"