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

I am fairly new to macro programming, but this one really has me stumped.
In moving a range of values from Book1.xls to Book2.xls, why does one of
these work and not the other?
In each case, the application is running in Book2, using Excel 2002 sp3 on
Windows XP. Both books are open.

This works:

Range("a1", "a10").Value = Workbooks("Book1.xls") _
.ActiveSheet.Range("a1", "a10").Value

However, this fails with run-time error 1004 "Application-defined or
object-defined error":

Range(Cells(1, 1), Cells(10, 1)).Value = Workbooks("Book1.xls") _
.ActiveSheet.Range(Cells(1, 1), Cells(10, 1)).Value

Can some please explain what is happening here.
Thanks, Robert


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Moving a range between workbooks

The Cells part of the macro need qualification. Without it, they refer to
the activesheet of the active workbook.

this modification should help

With Workbooks("Book1.xls").ActiveSheet
Range(Cells(1, 1), Cells(10, 1)).Value = _
.Range(.Cells(1, 1), .Cells(10, 1)).Value
End With


"Robert" wrote in message
...
I am fairly new to macro programming, but this one really has me stumped.
In moving a range of values from Book1.xls to Book2.xls, why does one of
these work and not the other?
In each case, the application is running in Book2, using Excel 2002 sp3 on
Windows XP. Both books are open.

This works:

Range("a1", "a10").Value = Workbooks("Book1.xls") _
.ActiveSheet.Range("a1", "a10").Value

However, this fails with run-time error 1004 "Application-defined or
object-defined error":

Range(Cells(1, 1), Cells(10, 1)).Value = Workbooks("Book1.xls") _
.ActiveSheet.Range(Cells(1, 1), Cells(10, 1)).Value

Can some please explain what is happening here.
Thanks, Robert




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Moving a range between workbooks

Thanks, Tim. Looks like I need to study the fundamentals some more.
Robert

"Tim Zych" wrote in message
...
The Cells part of the macro need qualification. Without it, they refer to
the activesheet of the active workbook.

this modification should help

With Workbooks("Book1.xls").ActiveSheet
Range(Cells(1, 1), Cells(10, 1)).Value = _
.Range(.Cells(1, 1), .Cells(10, 1)).Value
End With


"Robert" wrote in message
...
I am fairly new to macro programming, but this one really has me

stumped.
In moving a range of values from Book1.xls to Book2.xls, why does one of
these work and not the other?
In each case, the application is running in Book2, using Excel 2002 sp3

on
Windows XP. Both books are open.

This works:

Range("a1", "a10").Value = Workbooks("Book1.xls") _
.ActiveSheet.Range("a1", "a10").Value

However, this fails with run-time error 1004 "Application-defined or
object-defined error":

Range(Cells(1, 1), Cells(10, 1)).Value = Workbooks("Book1.xls") _
.ActiveSheet.Range(Cells(1, 1), Cells(10, 1)).Value

Can some please explain what is happening here.
Thanks, Robert






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
moving entries between workbooks acetoolguy Excel Worksheet Functions 1 January 31st 10 10:15 PM
Moving Data between sheets in the same workbook and moving data between Workbooks. Alison Brown Excel Worksheet Functions 0 February 10th 09 01:03 AM
Moving workbooks between folders Ozzie Excel Discussion (Misc queries) 3 January 25th 06 09:25 AM
moving workbooks kmd Excel Discussion (Misc queries) 1 October 26th 05 12:21 AM
Moving sheets between workbooks [email protected] Excel Discussion (Misc queries) 3 December 27th 04 07:14 PM


All times are GMT +1. The time now is 08:12 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"