Jaymond Flurrie
Well-known Member
- Joined
- Sep 22, 2008
- Messages
- 919
- Office Version
- 365
- Platform
- Windows
I'm using Excel 2010. I know how to put recordset into a range. I would need to put recordset into an array. This is the code I use to put it into a range:
And it works, returns 14 results (14 rows, 1 column). The difference should be on the last line, but how?
gives subscript out of range, so does
What's wrong? Do I need some to alter something else than that last row (where I copy it from the recordset to a range)?
Code:
Set rsData = New ADODB.Recordset
rsData.Open strSQL, strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText
If Not rsData.EOF Then
Range("A1").CopyFromRecordset rsData
Else
MsgBox "No records returned.", vbCritical
End If
Code:
vSRA = rsData.GetRows(14) 'vSRA is a variant
Range("A1") = vSRA(1, 1)
Code:
vSRA = rsData.GetRows
Range("A1") = vSRA(1)
Last edited: