View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Coco Coco is offline
external usenet poster
 
Posts: 34
Default ADO connection retrieving data to Excel using EXCEL-VBA

How can I tell the "recordset" during the process of pasting the data to the
spreadsheet, not to paste blank values, I mean, only import values < "" ONLY?
Thanks

Coco
This is my working fine ADO connection but it is retrieving ALL records for
that table, including Blank values.


DBConnection = "Provider=MSDASQL.1 ........."
SqlString = "SELECT UNITX,DESCRIPTION from UNIT"
Dim TargetRange As Range
Set TargetRange = Worksheets("Sheet1").Range("A1")
Dim cn As ADODB.Connection, rs As ADODB.Recordset, intColIndex As Integer
Set rs = New ADODB.Recordset
With rs
.Open SqlString, DBConnection
TargetRange.Offset(0, 0).CopyFromRecordset rs ' recordset data
End With
rs.Close
Set rs = Nothing