INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Copy from one Excel Workbook to another Excel Workbook with VBA

Copy from one Excel Workbook to another Excel Workbook with VBA

(OP)
I am using Excel 2010. I have an Excel workbook which has about 10 worksheets.
Each work sheet has a lot of data. There are a lot of cells and a lot of tables..

I also have another Workbook which has the same 10 excel work sheets in it.
However, all the fields in each worksheet are not in the same order as in the original Workbook.

That is, Workbook A field order is not the same order as the workbook B.

Also, the tables are about 30 rows X 20 columns each in both the Excel workbooks. Again, the rows and columns order in both source and destination is not exactly the same.

How can I copy the data from the Source Workbook to Destination workbook.
Please provide Excel VBA Code.

RE: Copy from one Excel Workbook to another Excel Workbook with VBA

HI,

I would not use COPY 'n' PASTE. Rather I'd use queries to the other sheets to bring the data into your workbook in the order you wish.

Data > Get external data > from other sources > Microsoft Query...

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Copy from one Excel Workbook to another Excel Workbook with VBA

The query method, as Skip suggests, will give a far better performance solution, and though it may seem tedious with the way the Query tool is setup, it should be the best solution.

If you're determined to use VBA, you'll need some tediously detailed code to make sure everything copies correctly. Basically, the route I'd take on that would be to match up the original column header with the new column header, assuming at least the field names are 100% identical. If they are not 100% identical, then you'll need to get even more tedious, which even more brings back to Skip's suggestion for MS Query.

Be sure to let us know whatever you end up doing.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close