insert copied cells to a different workbook

G

Guest

Helo

I have this code (see code below) and it works fine for me. Now I want to
alter it so the sheet it copys rows to (sheet "ALL"), is in a diferent
workbook (lets say "workbook2" which is on my desktop. How do I alter the
code below? and does workbook2 have to be open when I run the macro? (i'd
rather have it saved to without opening it if possible but this is not
critical)


Sheets("EXPORT").Select
lr = Cells(Rows.Count, "b").End(xlUp).Row
Range("a1:iv" & lr).copy
Sheets("ALL").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown
 
G

Guest

Using your code style and assuming the active wb is wb1:

Workbooks(1).Sheets("EXPORT").Select
lr = Cells(Rows.Count, "b").End(xlUp).Row
Range("a1:iv" & lr).copy
Workbooks(2).Sheets("ALL").Select
Rows("1:1").Select
Selection.EntireRow.Insert Shift:=xlDown
 
A

Alan

Will this help?

Sheets("EXPORT").Select
lr = Cells(Rows.Count, "b").End(xlUp).Row
Range("a1:iv" & lr).copy
Dim Wb2 As Workbook
Set Wb2 = Workbooks.Open(C:\Documents and
Settings\YourUserName\Desktop\Worbook2.xls
Sheets("ALL").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Wb2.Close True

Regards,

Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top