I am having a slight issue with resizing an array of data to my spreadsheet, hopefully someone can help. I use below code to write it to the sheet and it works
objRec = objRecordSet.GetRows
For r = LBound(objRec, 2) To UBound(objRec, 2)
For c = LBound(objRec, 1) To UBound(objRec, 1)
.Cells(r + 2, c + 1) = objRec(c, r)
Next c
Next r
now I am trying to use Resize and that is where the fun begins, I have below function (thought it would work, but does not)
Sub WriteArrayToSheet(vArray As Variant, StartAt As String, _ Optional bTranspose As Boolean = False)
With Range(StartAt)
Select Case bTranspose
Case True
.Resize(UBound(vArray, 2), _
UBound(vArray, 1)).Value = Application.Transpose(vArray)
Case False
.Resize(UBound(vArray, 1), _
UBound(vArray, 2)).Value = vArray
End Select
End With
End Sub
when i pass my array into the sub (without transposing it - it propagate across the columns), not what I want (works). I wanted the array to go down in rows. I set my bTranspose to true but I get an error??? What may be wrong with the transposing??