![]() |
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. |
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. |
All times are GMT +1. The time now is 11:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com