Reputation: 506
Is there a way to copy the values from a single column of a recordset to a column in Excel without have to use a loop? I tried the following to copy a single column:
Sheet4.Range("Complete").CopyFromRecordset rsEDW.Fields(3)
But that did not work.
Upvotes: 1
Views: 6803
Reputation: 510
EDIT: It looks a though you can copy just one column without a loop with the max column reference.
https://msdn.microsoft.com/en-us/library/office/aa223845%28v=office.11%29.aspx
I don't think there is anyway to do it without looping. You would have to loop through the record set and make each column a field from the record set.
With rs
Do Until .EOF
ActiveSheet.Range("A" & lastRow).CopyFromRecordset rsEDW.Fields(3)
ActiveSheet.Range("B" & lastRow).CopyFromRecordset rsEDW.Fields(4)
.MoveNext
lastRow = lastRow + 1
Loop
End With
Upvotes: 3