Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default insert copied cells to a different workbook

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default insert copied cells to a different workbook

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

"steven" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default insert copied cells to a different workbook

Workbook 2 should be open.

"steven" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default insert copied cells to a different workbook

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

"steven" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot insert cells copied from one workbook to another XiGuaSiamese Excel Discussion (Misc queries) 1 September 23rd 10 06:19 PM
Insert copied cells Martin B Excel Worksheet Functions 3 August 30th 06 10:47 PM
Insert Copied Cells? HockeyFan Excel Discussion (Misc queries) 2 February 17th 06 01:32 PM
Insert Copied Cells? HockeyFan[_2_] Excel Programming 0 February 16th 06 05:28 PM
insert copied cells maryj Excel Discussion (Misc queries) 1 October 24th 05 07:56 PM


All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"