Johnboy
Apr 22nd, 2005, 09:03 AM
I'm having a problem with XL2000 when setting the values of a Range object on a given worksheet to the contents of an array when that worksheet is not active (a different worksheet is selected/active). It works perfectly with this method:
Dim myArray(1 to 2, 1 to 5) as Double
'(Set myArray values here)
Worksheet("1").Range("A1:E2").Value = myArray
but I need to be able to use the "cells" method of defining a Range object. The following method does not work when the sheet containing the Range being set is not the active worksheet:
Dim myArray(1 to 2, 1 to 5) as Double
'(Set myArray values here)
Worksheet("1").Range(Cells(1 ,1), Cells(2,5)).Value = myArray
This method raised error #1004: "Application-defined or Object-defined error." I would greatly prefer to use the second method in my code because it suits my program much better. Does anyone know how to make it work without selecting the sheet? :confused:
Dim myArray(1 to 2, 1 to 5) as Double
'(Set myArray values here)
Worksheet("1").Range("A1:E2").Value = myArray
but I need to be able to use the "cells" method of defining a Range object. The following method does not work when the sheet containing the Range being set is not the active worksheet:
Dim myArray(1 to 2, 1 to 5) as Double
'(Set myArray values here)
Worksheet("1").Range(Cells(1 ,1), Cells(2,5)).Value = myArray
This method raised error #1004: "Application-defined or Object-defined error." I would greatly prefer to use the second method in my code because it suits my program much better. Does anyone know how to make it work without selecting the sheet? :confused: