View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
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.