Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
moving entries between workbooks | Excel Worksheet Functions | |||
Moving Data between sheets in the same workbook and moving data between Workbooks. | Excel Worksheet Functions | |||
Moving workbooks between folders | Excel Discussion (Misc queries) | |||
moving workbooks | Excel Discussion (Misc queries) | |||
Moving sheets between workbooks | Excel Discussion (Misc queries) |