View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_5_] GS[_5_] is offline
external usenet poster
 
Posts: 226
Default Using an ADODB.Recordset in Excel 2007

Robert Crandal wrote on 9/25/2010 :
I have seen a few code examples that use ADO to open a
"connection" to an Excel 2007 file. After a connection is established,
I typically see code such as this:

'=======================================
' Check to make sure we received data.
If Not rsData.EOF Then
Sheet1.Range("A1").CopyFromRecordset rsData
Else
MsgBox "No records returned.", vbCritical
End If
'======================================

The above code pastes data from the "rsData" recordset object
into Sheet1 starting at range A1. My question is, what if I don't
want to paste my recordset onto the spreedsheet?? Can't I
simply assign specific data values from the recordset to a Visuabl Basic
variable??

Thank you!


Yes! You don't have to write data to a spreadsheet because you can
manipulate the recordset however you want. You could, for example, dump
it into an array or parse individual records into variables.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc