Does anyone any experience with this?
I can do a parameter query from one cell, but I haven't been able to
expand the query.
Thanks,
Paul
Thanks for your help,
Paul
This is untested but it would go something like this:
Dim strSQL as string
Dim lRow as long
strSQL = "SELECT * FROM accounts WHERE acct_no IN ("
lRow = 1
With Sheets("MySheetName")
Do while not isempty(.cells(lrow,1))
strsql = strSQL & .cells(lrow,1).value & ","
lrow = lrow +1
loop
end with
strsql = left(strsql,len(strsql)-1) & ")"
HTH,
Robin Hammond
www.enhanceddatasystems.com
<paul....@gmail.com> wrote in message
news:1141155207.4...@u72g2000cwu.googlegroups.com...
You could also drive the query via VBA, but if the only reason to do that is
to accomodate the range it might not be worth the trouble.
Does that help?
***********
Regards,
Ron
XL2002, WinXP-Pro
Sub Multiquery1()
Dim strSQL As String
Dim lRow As Long
strSQL = "SELECT * FROM ACCOUNTS WHERE (ACCT_NO IN ('"
lRow = 1
With Sheets("Trade #")
Do While Not IsEmpty(.Cells(lRow, 1)) 'Assuming my values are in
A1
strSQL = strSQL & .Cells(lRow, 1).Value & "','" ' That's
singles quotes in there
lRow = lRow + 1
Loop
End With
strSQL = Left(strSQL, Len(strSQL) - 2) & "))" 'Removes the last ,'
Sheets("Display").Select
Range("A1").Select
With ActiveSheet.QueryTables(1)
.CommandType = xlCmdSql
.CommandText = strSQL
...
End With
End Sub