05-20-2009, 11:11 AM
Hi,
This would help you to query from the Excel Sheet
This would help you to query from the Excel Sheet
Code:
'Set oCnnExcel = CreateObject("ADODB.Connection")
'Set oRsExcel = CreateObject("ADODB.Recordset")
'DbExcelPath = "D:\Manojith_Others\All_others\Database.xls"
'oCnnExcel.Open "Driver={Microsoft Excel Driver (*.xls)};DBQ=" & Trim(DbExcelPath) & ";Readonly=1;" 'DSN
'oRsExcel.Open "SELECT * FROM [TEST_01_UC01$] WHERE IdNo IN ('123','124') ORDER BY IdNo, CompanySal, CompanyName Asc", oCnnExcel, 2, 3
'oRsExcel.MoveFirst
'Do While oRsExcel.EOF = False
' MsgBox oRsExcel.Fields("CompanyName").Value
' MsgBox oRsExcel.Fields("CompanySal").Value
' oRsExcel.MoveNext
'Loop