Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Copy from another workbook


Hi, I need to some code to enable all cells on sheet 1 of workbook A to be
copied into sheet 2 of workbook B.

I have done this before but for some reason I get an error message sayig
subscript out of range when I run the code.


It would also be really goo if I could incorporate code to open workbook A
from workbook B to minimise the user input even furtehr. A message bo asking
for the file name would be needed.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Copy from another workbook

Hi,
Place in Workbook B:

Sub CopyWbk()

'
Set wb1 = ThisWorkbook

wbName = Application.InputBox("Enter workbook name", Type:=2)

Workbooks.Open Filename:= _
"C:\" & wbName & ".xls"
Set wb2 = Workbooks(wbName)

wb1.Sheets("Sheet1").Cells.Copy wb2.Sheets("Sheet2").Range("A1")

End Sub

"Alan M" wrote:


Hi, I need to some code to enable all cells on sheet 1 of workbook A to be
copied into sheet 2 of workbook B.

I have done this before but for some reason I get an error message sayig
subscript out of range when I run the code.


It would also be really goo if I could incorporate code to open workbook A
from workbook B to minimise the user input even furtehr. A message bo asking
for the file name would be needed.


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
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Excel-how to link source workbook to copy of destination workbook D Lynn Excel Worksheet Functions 1 May 29th 08 05:36 PM
copy worksheet from closed workbook to active workbook using vba mango Excel Worksheet Functions 6 December 9th 04 07:55 AM
Need a macro to copy a range in one workbook and paste into another workbook Paul Excel Programming 8 July 1st 04 07:42 AM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM


All times are GMT +1. The time now is 12:58 PM.

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"