VBA: Copy Row from One Workbook to Another

nickshep85

New Member
Joined
Mar 21, 2012
Messages
37
I have a code which I use to import a large text file into as many worksheets as necessary. Text to Column is then run on these sheets and a formula added into Column I which returns TRUE or FALSE.

What I need my to do next is select any rows where the value in Cell I is TRUE and paste this into another workbook, ImportFile.xls, onto a tab labelled Mechanical. Where the value in Cell I is FALSE, the row needs to be copied into ImportFile.xls, Tyres tab.

In both of these new tabs, I have headers in Rows 1 & 2, so I would need any data to be inserted from Row 3 onwards.

There are 2 tabs in my original Workbook, PriceFile.xls, as there were 71,000 rows in my text file. The number of sheets may increase or decrease depending on the text files I use.

Can anyone please help me with this code, as I have no idea where I would need to start with this part. I have code that runs up to the creation of ImportFile.xls and inserts the headers on both tabs, but my knowledge is very limited so far and I'm stuck when I get to selecting rows and copying them over.

Many thanks for your help...
 
Andrew,

I think you're getting close now. However, the code has copied all the data from just one sheet of the PriceFile. It copied the first line from one tab and pasted it into the Tyres tab correctly, but then moved onto the next sheet and pasted all rows from that cell correctly.

Looking at how long it may take to run this code, based on file size, I might try to re-do some of the code to enable me to AutoFilter the data to make it easier to move the rows across.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,213,513
Messages
6,114,072
Members
448,546
Latest member
KH Consulting

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top