View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Joe HM Joe HM is offline
external usenet poster
 
Posts: 92
Default How to read Rows within a Column through ADO ...

Hello -

I needed more than just finding empty cells but I could actually figure
it out by myself

fullName = "C:\Book1.xls"
sConn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
fullName & _
";" & "Extended Properties=""Excel 8.0;HDR=NO"""
Set adoConn = New ADODB.Connection
adoConn.Open sConn

src = "SELECT * FROM [Sheet1$C47:C100]"
Set adoRs = New ADODB.Recordset
adoRs.Open Source:=src, ActiveConnection:=adoConn

If Not (adoRs.BOF Or adoRs.EOF) Then
adoRs.MoveFirst

Do While Not adoRs.EOF
lValue = adoRs.Fields(0).Value

If Not IsNull(lTEXT) Then
...
Else
Exit Do
End If

adoRs.MoveNext
Loop
Else
Debug.Print "No Record"
End If

adoRs.Close
adoConn.Close

That works like a charm and is way faster than opening the files
through Excel and parsing through the cells.

The only problem I saw is that if I have Column A and B merged for some
rows, I cannot read in what is in Column B even if I start below the
last merged cells. Is there a way to get to the data anyway?

Thanks again!
Joe