I’m new to working with recordsets, and I’m working on something where I retrieve a recordset from a sql server and then I need to loop through it pasting the values in an excel spreadsheet.
The order of the fields in the recordset is already correct, so I should be able to just move from cell to cell pasting each value within a range, but I’m not sure exactly how to do it. I know the recordset is correct because I outputed it to a file and everything looked in order.
This is my code so far:
Public Sub retrieve()
Dim rsTest As ADODB.Recordset
Set rsTest = New ADODB.Recordset
Set rsTest = DataManager.GetData()
Sheets("Planners").Activate
Dim cel As Range
Dim i As Integer
Dim rsFields As Variant
Do While Not rsTest.EOF
For Each cel In ActiveSheet.Range("A3:H1000").Cells
For Each rsFields In rsTest.Fields
cel = rsTest(rsFields.Name)
Next
Next
Loop
End Sub
Thanks in advance for any and all help.
If you want all the recordset fields then you can just do this: