![]() |
copying data from one book to another
I want to import some info from book2 into book1, I thought it could be done
by having both files open at the same time and running a macro form book1. The information to copy/import is in cells or ranges of cells. For example, cell D12 (sheet1) in book2 needs to go into cell C4 (sheet1) in book1. There are about 150 values to be copied/imported all together. That's about as far as I have got and any help would be gratefully received. Gareth |
copying data from one book to another
Workbooks("Book2.xls").Worksheets("Sheet1").Range( "D12").Value = _
Workbooks("Book1.xls").Worksheets("Sheet1").Range( "C4").Value -- Regards, Tom Ogilvy "Gareth" wrote in message ... I want to import some info from book2 into book1, I thought it could be done by having both files open at the same time and running a macro form book1. The information to copy/import is in cells or ranges of cells. For example, cell D12 (sheet1) in book2 needs to go into cell C4 (sheet1) in book1. There are about 150 values to be copied/imported all together. That's about as far as I have got and any help would be gratefully received. Gareth |
copying data from one book to another
obviously I misled you........
the files names will not always be known. Gareth "Tom Ogilvy" wrote in message ... Workbooks("Book2.xls").Worksheets("Sheet1").Range( "D12").Value = _ Workbooks("Book1.xls").Worksheets("Sheet1").Range( "C4").Value -- Regards, Tom Ogilvy "Gareth" wrote in message ... I want to import some info from book2 into book1, I thought it could be done by having both files open at the same time and running a macro form book1. The information to copy/import is in cells or ranges of cells. For example, cell D12 (sheet1) in book2 needs to go into cell C4 (sheet1) in book1. There are about 150 values to be copied/imported all together. That's about as far as I have got and any help would be gratefully received. Gareth |
copying data from one book to another
On Sun, 10 Jul 2005 20:35:24 +0100, "Gareth" wrote: obviously I misled you........ the files names will not always be known. Gareth "Tom Ogilvy" wrote in message ... Workbooks("Book2.xls").Worksheets("Sheet1").Range( "D12").Value = _ Workbooks("Book1.xls").Worksheets("Sheet1").Range( "C4").Value -- Regards, Tom Ogilvy "Gareth" wrote in message ... I want to import some info from book2 into book1, I thought it could be done by having both files open at the same time and running a macro form book1. The information to copy/import is in cells or ranges of cells. For example, cell D12 (sheet1) in book2 needs to go into cell C4 (sheet1) in book1. There are about 150 values to be copied/imported all together. That's about as far as I have got and any help would be gratefully received. Gareth Gareth The general approach I always adopt in this situation is as follows. Sub testcopy() Dim mywb As Workbook Dim tempwb As Workbook Set mywb = ActiveWorkbook Application.Workbooks.Open ("book2.xls") <or if you don't know the filename so that you can code it Application.GetOpenFilename Set tempwb = ActiveWorkbook Worksheets("sheet1").Range("d12").Copy mywb.Activate Worksheets("sheet1").Range("c4").PasteSpecial (xlPasteAll) End Sub You'd need to adapt this approach to deal with the 150 cells you're trying to handle, but it shouldn't be too difficult. Rgds __ Richard Buttrey Grappenhall, Cheshire, UK __________________________ |
All times are GMT +1. The time now is 12:54 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com