B
Bobsa
I'm having problems assigning an array back to a worksheet created
with the CreateObject method.
Once the array has been processed and is in memory I can use this line
Range(Cells(1, 1), Cells(NewDataRowNumber + 1, ExpandedLastColumn)) =
NewPositionsArray
to assign it back fine to the instance of excel I'm using to process
and control everything from.
but when I use it with "With xlapp" .....in the form....
..Range(Cells(1, 1), Cells(NewDataRowNumber + 1, ExpandedLastColumn)) =
NewPositionsArray
I get an "object application defined error"
If I manually type the address for test purposes this works
..Range("a1:AO166") = NewPositionsArray
But I cannot understand why the ... .Range(Cells(1, 1),..... doesn't
work
Below is a snippet of code with both bits in the right place...
obviously only one is used at runtime.....
any help appreciated.
Bobsa
==================================
Dim xlapp As Object
Set xlapp = CreateObject("Excel.Application")
With xlapp
.Visible = True
.Workbooks.Add
End With
'between these points there is a lot of code which creates an array
called
'NewPositionsArray
With xlapp
.Workbooks(1).Activate
.Selection.Delete 'clear the area to receive the array
.Range("a1").Select 'just used to test if this is active
.Range("a1:AO166") = NewPositionsArray 'this works inside the
object
.Range(Cells(1, 1), Cells(NewDataRowNumber + 1,
ExpandedLastColumn)) = NewPositionsArray
'I would like to use this style
End With
with the CreateObject method.
Once the array has been processed and is in memory I can use this line
Range(Cells(1, 1), Cells(NewDataRowNumber + 1, ExpandedLastColumn)) =
NewPositionsArray
to assign it back fine to the instance of excel I'm using to process
and control everything from.
but when I use it with "With xlapp" .....in the form....
..Range(Cells(1, 1), Cells(NewDataRowNumber + 1, ExpandedLastColumn)) =
NewPositionsArray
I get an "object application defined error"
If I manually type the address for test purposes this works
..Range("a1:AO166") = NewPositionsArray
But I cannot understand why the ... .Range(Cells(1, 1),..... doesn't
work
Below is a snippet of code with both bits in the right place...
obviously only one is used at runtime.....
any help appreciated.
Bobsa
==================================
Dim xlapp As Object
Set xlapp = CreateObject("Excel.Application")
With xlapp
.Visible = True
.Workbooks.Add
End With
'between these points there is a lot of code which creates an array
called
'NewPositionsArray
With xlapp
.Workbooks(1).Activate
.Selection.Delete 'clear the area to receive the array
.Range("a1").Select 'just used to test if this is active
.Range("a1:AO166") = NewPositionsArray 'this works inside the
object
.Range(Cells(1, 1), Cells(NewDataRowNumber + 1,
ExpandedLastColumn)) = NewPositionsArray
'I would like to use this style
End With