View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.links
LarryP LarryP is offline
external usenet poster
 
Posts: 73
Default Run SQL against Access DB/Filter Results

That looks promising, if I can build a string long enough to hold,
potentially, thousands of part numbers. (Most of the time it'll be in the
3-digit realm, I think, but there's always the worst case to consider.)
Thanks, Bill, I'll re-post after I try it.

"Bill Manville" wrote:

How about creating a WHERE clause along the lines of:
PartNumber IN ('12345', '23456', ..... )
and using that in your query?

Code would be something like this:
Dim C As Range
Dim stWhere As String
For Each C In Range("PartNumbers").Cells
stWhere = stwhere & "'" & C.Value & "', "
Next
stWhere = " PartNumber IN (" & Left(stWhere, Len(stWhere)-2) & ")"

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup