I have been trying to transpose an array to paste records from a ADODB.recordset into an excel row. (The records are stored in a 2D Variant array). However, whenever I try something like the first row of the code below, I get a 13: type mismatch error code. I therefore tried to dig down into seeing exactly where the error lay, and built a simple integer 2d array. It appears that the transpose function can't do this transposition either without throwing a 13 error code. Research online seemed to suggest this error is caused when the number of elements being transposed exceed 64k but this can't be it below. Any thoughts?
varRecords = rs2.GetRows(3) ' rs2 is a ADOBD.Recordset
intNumReturned = UBound(varRecords, 2) + 1
intNumColumns = UBound(varRecords, 1) + 1
For intRow = 0 To intNumReturned - 1
For intColumn = 0 To intNumColumns - 1
Debug.Print varRecords(intColumn, intRow)
Next intColumn
Next intRow
Dim Destination As Range
Set Destination = Range("k1")
Dim i, j As Integer
'Destination.Resize(UBound(varRecords, 2) + 1, UBound(varRecords, 1) + 1).Value = Application.Transpose(varRecords) - COMMENTED OUT BECAUSE IT ERRORS TYPE 13 TYPE MISMATCH
Dim myarr(3, 4) As Integer
myarr(0, 1) = 4
myarr(2, 4) = 6
Dim myvar As Variant
Set myvar = Application.Transpose(myarr) ' - ERROR THROWN HERE
Set
keyword:myvar = Application.Transpose(myarr)
– Dmitry PavlivvarRecords
is instantiated, assigned, and its dimensions. Also please indicate what specific error message you get on that line. Cheers. – David Zemensnull
in the resulting array.Transpose
cannot process nulls. – ZygD