Link to home
Start Free TrialLog in
Avatar of Jenkins
JenkinsFlag for United States of America

asked on

Copy a range of cells between two Excel files

I have two Excel files. They both reside on the Desktop of my C: drive.  One is named Source. One is named Target.  Each one has 10 tabs named "1", "2", "3", "4" etc.   I need a routine that will copy a range of cells (D20 to F30), including the source formatting, from each tab of the source file to each related tab of the target file (i.e. from tab 1 of the source file to tab 1 of the target file, tab 2 of the source to tab 2 of the target, etc.)   The data is different in each tab of the source file but the range of cells in each tab that I need to copy over is the same.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jenkins

ASKER

The macros through the end as evidenced by the message box message but nothing gets populated in the target file.    By the way, I'm dealing with macro-enabled worksheets, so I had to change the extension to .xlsm.

Again, what I'm trying to accomplish is have the data in the selected range from tab1 be copied into that range in tab 1 of the target file, data in the selected range from tab 2 be copied into that range in tab 2 of the target file, etc, etc..... for all tabs in the workbook.    The number of tabs and names of tabs are the same in both files.
In sktneer code...

Change line no-->14 which is this...

sws.Range("D20:F30").Copy twb.Sheets(sws.Name).Range("D20")

Open in new window


To this...

sws.Range("D20:F30").Copy twb.Sheets("" & sws.Name & "").Range("D20")

Open in new window


This should fix what you are trying to do..

Saurabh...