View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John[_67_] John[_67_] is offline
external usenet poster
 
Posts: 2
Default One-D Array to Column Problem

Greetings All,

The following code is *supposed* to take data returned from a database
query, extract one field of data to a 1-D array, and place it in a
column of a worksheet:

PasteRange = RecSet.GetRows
ReDim ReturnVals(0 To (UBound(PasteRange, 2) - 1))
For Index = 0 To UBound(PasteRange, 2) - 1
ReturnVals(Index) = PasteRange(2, Index)
Next
Range("AP7:AP469").Value =
Application.WorksheetFunction.Transpose(ReturnVals )

Stepping through in the VB editor shows that the 1-D array indeed
contains the correct information. The last line, however, always
errors out with "Type Mismatch".

Other info: PasteRange and ReturnVals are both Dim'd variant, and the
ODBC query always returns 462 rows. I'm only using the UBound stuff
so there's fewer lines of code to change if the database changes.

Any ideas?

-John