You are on page 1of 1

Call ReadDateFromExcel("C:\QAIssuesLog\QAIssuesLog.

xls", "QAIssues")
Function ReadDataFromExcel(sFileNameAndPath, sSheetName)
Dim conn
Set conn = CreateObject("ADODB.Connection")
With conn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & sFileNameAndPath & ";" & "Exten
ded Properties=Excel 8.0;"
.Open
End With
Dim sSQL,rs,vRows, strtext
Set rs = CreateObject("ADODB.Recordset")
sSQL = "SELECT * FROM [" & sSheetName & "$]"
rs.open sSQL, conn
i=0
do while not rs.eof
for each field in rs.fields
if Trim(strtext)="" then
strtext=strtext & field.value
else
strtext=strtext & " " & field.value
end if
next
i=i+1
rs.moveNext()
loop
rs.close
Set rs = nothing
conn.close
Set conn = nothing
vRows=Split(strtext,vbTab)
ReadDataFromExcel=vRows
End Function

You might also like