Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default 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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 296
Default 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
__________________________
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
Keeping Workbook Name Out of Sheet When Copying to Different Book navel151 Excel Discussion (Misc queries) 2 April 14th 10 01:02 PM
Copying multiple sheets from one book 2 another and undertake spec Pank Mehta Excel Discussion (Misc queries) 14 March 16th 05 04:41 PM
Copying multiple sheets to a new book and undertake specialised ed Pank Mehta Excel Discussion (Misc queries) 0 February 8th 05 12:03 PM
Copying Worksheets from one book to another Jonx[_8_] Excel Programming 2 August 17th 04 08:25 PM
macro stops copying sheets into a book after the 11th sheet MISMitch Excel Programming 1 October 22nd 03 05:27 PM


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

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

About Us

"It's about Microsoft Excel"