Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy between workbooks

I'm trying to copy a value from workbook sam to wokbook john. Workbook john
has multiple sheets. Cell a2 in sam will have the name of the sheet in john
to which I want to paste the value from a3 in sam.

In general, I'm confused about workbook vs. workbooks, worksheet vs.
worksheets, etc.


  #2   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Copy between workbooks

Hi Wolfie,

A workbook object is an Excel file.
Workbooks is a collection object consisting of all the workbook objects
currently open in a running instance of Excel.

A worksheet object is a spreadsheet in an Excel workbook.
Worksheets is a collection object consisting of all the worksheet objects in
an Excel workbook.


To copy the values between workbooks, you need to write a macro in a
standard module, something like this:

Sub CopyToOtherBook()
Dim rngSource As Range, rngTarget As Range

Set rngSource = Workbooks("sam.xls").Sheets("Sheet1").Range("A3")
'Substitute the sheetname used here with the name of the sheet containing
the data you want to copy


Set rngTarget =
Workbooks("john.xls").Sheets(rngSource.Offset(-1).Value).Range("A1")
'Substitute the range address used here with the one you want the data
copied to

'Copy the data
rngSource.Copy Destination:=rngTarget

End Sub

HTH
Regards,
GS

"Wolfie" wrote:

I'm trying to copy a value from workbook sam to wokbook john. Workbook john
has multiple sheets. Cell a2 in sam will have the name of the sheet in john
to which I want to paste the value from a3 in sam.

In general, I'm confused about workbook vs. workbooks, worksheet vs.
worksheets, etc.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Copy between workbooks

i do about the same thing, but would use this as the last line to copy the 1
value

rngTarget = rngSource

without the copy and destination

just a preference


--


Gary


"GS" wrote in message
...
Hi Wolfie,

A workbook object is an Excel file.
Workbooks is a collection object consisting of all the workbook objects
currently open in a running instance of Excel.

A worksheet object is a spreadsheet in an Excel workbook.
Worksheets is a collection object consisting of all the worksheet objects in
an Excel workbook.


To copy the values between workbooks, you need to write a macro in a
standard module, something like this:

Sub CopyToOtherBook()
Dim rngSource As Range, rngTarget As Range

Set rngSource = Workbooks("sam.xls").Sheets("Sheet1").Range("A3")
'Substitute the sheetname used here with the name of the sheet containing
the data you want to copy


Set rngTarget =
Workbooks("john.xls").Sheets(rngSource.Offset(-1).Value).Range("A1")
'Substitute the range address used here with the one you want the data
copied to

'Copy the data
rngSource.Copy Destination:=rngTarget

End Sub

HTH
Regards,
GS

"Wolfie" wrote:

I'm trying to copy a value from workbook sam to wokbook john. Workbook john
has multiple sheets. Cell a2 in sam will have the name of the sheet in john
to which I want to paste the value from a3 in sam.

In general, I'm confused about workbook vs. workbooks, worksheet vs.
worksheets, etc.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Copy between workbooks

Why don't you just use the Sheet copy menus? Click on the TAB you
want copied. Put in the target Workbook, decide where you want it
put, and be sure to check the box to COPY file, click OK.

  #5   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Copy between workbooks

Because the OP wants to copy a value from a range, not the entire sheet.

Regards,
GS

" wrote:

Why don't you just use the Sheet copy menus? Click on the TAB you
want copied. Put in the target Workbook, decide where you want it
put, and be sure to check the box to COPY file, click OK.




  #6   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Copy between workbooks

Hi Gary,

You raise a good point. I too prefer to use that technique. I don't know why
I malfunctioned here, but thanks for mentioning it.

Regards,
Garry
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Copy between workbooks

i find myself doing the same thing sometimes, must be subconscious or
something<g

--


Gary


"GS" wrote in message
...
Hi Gary,

You raise a good point. I too prefer to use that technique. I don't know why
I malfunctioned here, but thanks for mentioning it.

Regards,
Garry



  #8   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default Copy between workbooks

I might be just that! I do it constantly when I'm first writing the code.
Then I tune it up afterwards. It's good to keep the dot processing to a
minmum.<IMO

I appreciate the input!
Regards,
Garry

"Gary Keramidas" wrote:

i find myself doing the same thing sometimes, must be subconscious or
something<g

--


Gary


"GS" wrote in message
...
Hi Gary,

You raise a good point. I too prefer to use that technique. I don't know why
I malfunctioned here, but thanks for mentioning it.

Regards,
Garry




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Copy between workbooks

Thanks GS, that worked well!

W

"GS" wrote in message
...
Hi Wolfie,

A workbook object is an Excel file.
Workbooks is a collection object consisting of all the workbook objects
currently open in a running instance of Excel.

A worksheet object is a spreadsheet in an Excel workbook.
Worksheets is a collection object consisting of all the worksheet objects
in
an Excel workbook.


To copy the values between workbooks, you need to write a macro in a
standard module, something like this:

Sub CopyToOtherBook()
Dim rngSource As Range, rngTarget As Range

Set rngSource = Workbooks("sam.xls").Sheets("Sheet1").Range("A3")
'Substitute the sheetname used here with the name of the sheet containing
the data you want to copy


Set rngTarget =
Workbooks("john.xls").Sheets(rngSource.Offset(-1).Value).Range("A1")
'Substitute the range address used here with the one you want the data
copied to

'Copy the data
rngSource.Copy Destination:=rngTarget

End Sub

HTH
Regards,
GS

"Wolfie" wrote:

I'm trying to copy a value from workbook sam to wokbook john. Workbook
john
has multiple sheets. Cell a2 in sam will have the name of the sheet in
john
to which I want to paste the value from a3 in sam.

In general, I'm confused about workbook vs. workbooks, worksheet vs.
worksheets, etc.





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
copy between workbooks Carmela Excel Worksheet Functions 3 January 8th 10 08:24 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Copy between workbooks error Mike Fitz Excel Discussion (Misc queries) 2 July 24th 07 09:22 PM
copy from different workbooks into one GARDNERGUY Excel Worksheet Functions 0 March 22nd 07 03:48 AM
Can't copy between workbooks Sibil71 Excel Discussion (Misc queries) 10 November 2nd 06 07:02 PM


All times are GMT +1. The time now is 03:06 PM.

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"