Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy data from wb to another

Status
Not open for further replies.

sds814

Programmer
Feb 18, 2008
164
US
A user asked me a question of how to copy rows of data from one book to another using VBA. What he's trying to do is more complex so that's why he asked me how to do it in VBA.

Are there any links or some guidance that someone can provide for the VBA code?

It seems like my question is similar to the one posted by mattloflin except that the user has the 2 workbooks already created and the data is already populated.

Thanks.
 
Turn on your macro recorder (Tools < Macro > Record New Macro) and copy the worksheet from one workbook to the other. This can be accomplished by Right Clicking on the Sheet Tab and choosing Move or Copy. In the To Book section, select your target workbook. In the Before Sheet section, select where you want to put the copied workbook.

Now you have all of the rows in the target workbook.

So all that is left is to delete all rows that don't match your criteria. My preferred method for doing this is with AutoFilter (it runs faster than a loop). Depending on your criteria, you might need to loop through the rows instead. Looping was covered in mattloflin's thread.

Post back with the code generated by your macro recorder and some examples of the criteria you're looking for.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top