Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read an excel file one rwo at at time? 1

Status
Not open for further replies.

wvdba

IS-IT--Management
Jun 3, 2008
465
US
Hi.
i have a user that sends me a list of names a few times a week. i have a query that i type these names in the select statement to list the result from an oracle database table. i want to put this process in a script where he will send his data in an excel file and i will use that excel file to get a list of names. i have figured out the connection string to oracle, the query string and other code. the only part that i haven't been able to code is reading the excel file one row at a time until the name box is empty.
the excel file has the format:
LAST_NAME, FIRST_NAME, MIDDLE_NAME, DOB
Any suggestions?
thanks.
 



Here is a function that returns a list that you can put in your SQL IN () clause.
Code:
Function MakeList(rng As Range) As String
'SkipVought/2005 Jun 13/
'--------------------------------------------------
' Access: N/A
'--------------------------------------------------
'this function returns a single-quoted list that can be used, for instance _
in an IN Clause in SQL _
"WHERE PART_ID IN (" & [b]MakeList([SomeRange])[/b] & ")"
'--------------------------------------------------
    Dim r As Range
    Const TK = "'"
    Const CM = ","
    For Each r In rng
        With r
            MakeList = MakeList & TK & Trim(.Value) & TK & CM
        End With
    Next
    MakeList = Left(MakeList, Len(MakeList) - 1)
End Function


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
thanks very much.
it worked perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top