<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Multiple Parameters in External Data Queries</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 18:06:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Dick Kusleika</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30278</link>
		<dc:creator>Dick Kusleika</dc:creator>
		<pubDate>Fri, 01 Feb 2008 15:48:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30278</guid>
		<description>&lt;p&gt;Get well, DMU.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Get well, DMU.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DM Unseen</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30274</link>
		<dc:creator>DM Unseen</dc:creator>
		<pubDate>Fri, 01 Feb 2008 14:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30274</guid>
		<description>&lt;p&gt;All,&lt;/p&gt;
&lt;p&gt;I&#039;ve been Ill this week, so it will be next week I&#039;ll send something to Dick.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>All,</p>
<p>I&#8217;ve been Ill this week, so it will be next week I&#8217;ll send something to Dick.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick Kusleika</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30164</link>
		<dc:creator>Dick Kusleika</dc:creator>
		<pubDate>Tue, 29 Jan 2008 03:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30164</guid>
		<description>&lt;p&gt;DMU: You can mail it to me if you want me to host a file.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>DMU: You can mail it to me if you want me to host a file.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30157</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Mon, 28 Jan 2008 14:42:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30157</guid>
		<description>&lt;p&gt;DM Unseen,&lt;br&gt;
Thanks in advance for your time....if it is not possible to post it here could you kindly e-mail it to sgbhide At gmail dot com&lt;/p&gt;
&lt;p&gt;sam&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>DM Unseen,<br />
Thanks in advance for your time&#8230;.if it is not possible to post it here could you kindly e-mail it to sgbhide At gmail dot com</p>
<p>sam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DM Unseen</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30100</link>
		<dc:creator>DM Unseen</dc:creator>
		<pubDate>Sun, 27 Jan 2008 16:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30100</guid>
		<description>&lt;p&gt;First, this example is for SQL Server (and your error indicates Access), I have not studied to create this for Access, Although it is certainly possible.&lt;/p&gt;
&lt;p&gt;I&#039;ll try to get something, but this will be on monday. I&#039;m not sure how to upload it here btw.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>First, this example is for SQL Server (and your error indicates Access), I have not studied to create this for Access, Although it is certainly possible.</p>
<p>I&#8217;ll try to get something, but this will be on monday. I&#8217;m not sure how to upload it here btw.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30094</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Sun, 27 Jan 2008 11:36:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30094</guid>
		<description>&lt;p&gt;DM Unseen,&lt;br&gt;
I just tried your method...it gave me an error &quot;Too few parameters expected 1? .... could you kindly post a file containing the query.... &lt;/p&gt;
&lt;p&gt;sam&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>DM Unseen,<br />
I just tried your method&#8230;it gave me an error &#8220;Too few parameters expected 1? &#8230;. could you kindly post a file containing the query&#8230;. </p>
<p>sam</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DM Unseen</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30028</link>
		<dc:creator>DM Unseen</dc:creator>
		<pubDate>Thu, 24 Jan 2008 12:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30028</guid>
		<description>&lt;p&gt;Oops! As the parameter for the query you should of course select B10&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Oops! As the parameter for the query you should of course select B10</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DM Unseen</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-30025</link>
		<dc:creator>DM Unseen</dc:creator>
		<pubDate>Thu, 24 Jan 2008 12:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-30025</guid>
		<description>&lt;p&gt;There is a trick for doing a SQL query for a fixed range of products/customers from inside Excel without programming:&lt;/p&gt;
&lt;p&gt;I will show this for a sql server query. I will omit the standard steps from this post, but i will show the specifics.&lt;/p&gt;
&lt;p&gt;Step 1:&lt;/p&gt;
&lt;p&gt;Use a fixed range/list to put all customer id&#039;s. For e.g. A1-A10:&lt;br&gt;
CUST1&lt;br&gt;
CUST2&lt;br&gt;
CUST3&lt;br&gt;
....&lt;br&gt;
CUST10&lt;/p&gt;
&lt;p&gt;Step2&lt;/p&gt;
&lt;p&gt;Create a formula in adjectant cell B1:&lt;br&gt;
=&quot;&#124;&quot;&amp; A1 &amp; &quot;&#124;&quot;    (equals &quot;&#124;CUST1&#124;&quot;)&lt;br&gt;
Create a formula in B2&lt;br&gt;
=B1 &amp; A2 &amp; &quot;&#124;&quot;   (equals &quot;&#124;CUST1&#124;CUST2&#124;&quot;)&lt;/p&gt;
&lt;p&gt;Fill the formula in B2 down for all the customers (till A10)&lt;/p&gt;
&lt;p&gt;Create a Query (maybe on another sheet):&lt;/p&gt;
&lt;p&gt;SELECT * FROM CUSTOMERS WHERE ? LIKE &#039;%&#124;&#039; + CUSTOMER_ID + &#039;&#124;%&#039;&lt;/p&gt;
&lt;p&gt;Refresh the query and select as the parameter the cell A10&lt;/p&gt;
&lt;p&gt;You should only see a list of customers that you entered in A1-A10.&lt;/p&gt;
&lt;p&gt;Note the following&lt;/p&gt;
&lt;p&gt;For SQL server the limit is 8000 characters long, which is can contain quite a number of customer id&#039;s, but depending on the length of the customer id not hundreds or more (check the length of the text in A10).&lt;/p&gt;
&lt;p&gt;This trick also works even if not all customer ids are filled.&lt;/p&gt;
&lt;p&gt;Also, this is not a super fast query.&lt;/p&gt;
&lt;p&gt;Several variations on this theme can be used with different database platforms and range of parameters.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>There is a trick for doing a SQL query for a fixed range of products/customers from inside Excel without programming:</p>
<p>I will show this for a sql server query. I will omit the standard steps from this post, but i will show the specifics.</p>
<p>Step 1:</p>
<p>Use a fixed range/list to put all customer id&#8217;s. For e.g. A1-A10:<br />
CUST1<br />
CUST2<br />
CUST3<br />
&#8230;.<br />
CUST10</p>
<p>Step2</p>
<p>Create a formula in adjectant cell B1:<br />
=&#8221;|&#8221;&amp; A1 &amp; &#8220;|&#8221;    (equals &#8220;|CUST1|&#8221;)<br />
Create a formula in B2<br />
=B1 &amp; A2 &amp; &#8220;|&#8221;   (equals &#8220;|CUST1|CUST2|&#8221;)</p>
<p>Fill the formula in B2 down for all the customers (till A10)</p>
<p>Create a Query (maybe on another sheet):</p>
<p>SELECT * FROM CUSTOMERS WHERE ? LIKE &#8216;%|&#8217; + CUSTOMER_ID + &#8216;|%&#8217;</p>
<p>Refresh the query and select as the parameter the cell A10</p>
<p>You should only see a list of customers that you entered in A1-A10.</p>
<p>Note the following</p>
<p>For SQL server the limit is 8000 characters long, which is can contain quite a number of customer id&#8217;s, but depending on the length of the customer id not hundreds or more (check the length of the text in A10).</p>
<p>This trick also works even if not all customer ids are filled.</p>
<p>Also, this is not a super fast query.</p>
<p>Several variations on this theme can be used with different database platforms and range of parameters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hamilton</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-29980</link>
		<dc:creator>Hamilton</dc:creator>
		<pubDate>Mon, 21 Jan 2008 01:05:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-29980</guid>
		<description>&lt;p&gt;Thanks for the concise info on how to get parameters from cells into table queries of external data in Excel.  I lucked out, your post came up first on Google!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for the concise info on how to get parameters from cells into table queries of external data in Excel.  I lucked out, your post came up first on Google!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://www.dailydoseofexcel.com/archives/2008/01/17/multiple-parameters-in-external-data-queries/#comment-29965</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Sat, 19 Jan 2008 14:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1795#comment-29965</guid>
		<description>&lt;p&gt;Dick, Brett..&lt;br&gt;
Thanks for those suggestions.&lt;/p&gt;
&lt;p&gt;I just modified the code...changed WHERE/OR to WHERE IN and used a String to Array Function....ran a query of about 5000 Customer ID&#039;s typed in a range of cells... works great... thanks for this post..&lt;/p&gt;
&lt;div style=&quot;overflow: auto; white-space: nowrap;&quot; class=&quot;codecolorer-container vb default&quot;&gt;&lt;div style=&quot;white-space: nowrap;&quot; class=&quot;vb codecolorer&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Option&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Explicit&lt;/span&gt;&lt;br&gt;
&#160;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; QSC_PARM()&lt;br&gt;
&lt;span class=&quot;co1&quot;&gt;&#039;Queries the Customer Master&lt;br&gt;
&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; Ar &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, Ar1 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, Ar2 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, Ar3 &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; SorSht &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;, QryNm &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; DestSht &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; Worksheet&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; i &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&#160;&lt;br&gt;
SorSht = &lt;span class=&quot;st0&quot;&gt;&quot;Sheet1$&quot;&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Set&lt;/span&gt; DestSht = Sheet2&lt;br&gt;
&#160;QryNm = &lt;span class=&quot;st0&quot;&gt;&quot;QRY_PARM&quot;&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; RngArr(1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; Range(&lt;span class=&quot;st0&quot;&gt;&quot;ID&quot;&lt;/span&gt;).Count)&lt;br&gt;
&#160;&lt;br&gt;
Ar1 = &lt;span class=&quot;st0&quot;&gt;&quot;ODBC;DSN=Excel Files;DBQ=&quot;&lt;/span&gt; &amp; Range(&lt;span class=&quot;st0&quot;&gt;&quot;VBA_FPN&quot;&lt;/span&gt;).Value &amp; &lt;span class=&quot;st0&quot;&gt;&quot;;DefaultDir=&quot;&lt;/span&gt; &amp; Range(&lt;span class=&quot;st0&quot;&gt;&quot;VBA_FP&quot;&lt;/span&gt;).Value &amp; &lt;span class=&quot;st0&quot;&gt;&quot;;DriverId=790;MaxBufferSize=2048;PageTimeout=5;&quot;&lt;/span&gt;&lt;br&gt;
Ar = &lt;span class=&quot;st0&quot;&gt;&quot;SELECT *&quot;&lt;/span&gt;&lt;br&gt;
Ar2 = Ar &amp; &lt;span class=&quot;st0&quot;&gt;&quot;&quot;&lt;/span&gt; &amp; Chr(10) &amp; &lt;span class=&quot;st0&quot;&gt;&quot;FROM &#039;&quot;&lt;/span&gt; &amp; Range(&lt;span class=&quot;st0&quot;&gt;&quot;VBA_FPN1&quot;&lt;/span&gt;).Value &amp; &lt;span class=&quot;st0&quot;&gt;&quot;&#039;.&#039;&quot;&lt;/span&gt; &amp; SorSht &amp; &lt;span class=&quot;st0&quot;&gt;&quot;&#039; &#039;&quot;&lt;/span&gt; &amp; SorSht &amp; &lt;span class=&quot;st0&quot;&gt;&quot;&#039;&quot;&lt;/span&gt; &amp; Chr(10) &amp; Chr(13) &amp; &lt;span class=&quot;st0&quot;&gt;&quot;WHERE &#039;&quot;&lt;/span&gt; &amp; SorSht &amp; &lt;span class=&quot;st0&quot;&gt;&quot;&#039;.ID IN (&quot;&lt;/span&gt;&lt;br&gt;
Ar3 = Range(&lt;span class=&quot;st0&quot;&gt;&quot;ID&quot;&lt;/span&gt;)(1).Value&lt;br&gt;
&#160;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i = 2 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; Range(&lt;span class=&quot;st0&quot;&gt;&quot;ID&quot;&lt;/span&gt;).Count&lt;br&gt;
Ar3 = Ar3 &amp; &lt;span class=&quot;st0&quot;&gt;&quot;, &quot;&lt;/span&gt; &amp; Range(&lt;span class=&quot;st0&quot;&gt;&quot;ID&quot;&lt;/span&gt;)(i).Value&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; i&lt;br&gt;
&#160;&lt;br&gt;
Ar2 = Ar2 &amp; Ar3 &amp; &lt;span class=&quot;st0&quot;&gt;&quot;)&quot;&lt;/span&gt;&lt;br&gt;
&#160;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;With&lt;/span&gt; DestSht.QueryTables(QryNm)&lt;br&gt;
Ar3 = Replace(Ar1, &lt;span class=&quot;st0&quot;&gt;&quot;ODBC&quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&quot;OLEDB&quot;&lt;/span&gt;, 1, 1)&lt;br&gt;
.Connection = Ar3&lt;br&gt;
.CommandText = StringToArray(Ar2)&lt;br&gt;
.Connection = Ar1&lt;br&gt;
.CommandText = StringToArray(Ar2)&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;With&lt;/span&gt;&lt;br&gt;
DestSht.QueryTables(QryNm).Refresh BackgroundQuery:=&lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;br&gt;
&#160;&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt; StringToArray(Query &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;&lt;br&gt;
&#160;&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Const&lt;/span&gt; StrLen = 127&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; NumElems &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Integer&lt;/span&gt;&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; Temp() &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; i &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Long&lt;/span&gt;&lt;br&gt;
&#160; &#160;NumElems = (Len(Query) / StrLen) + 1&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;ReDim&lt;/span&gt; Temp(1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; NumElems) &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; i = 1 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; NumElems&lt;br&gt;
&#160; &#160; &#160; Temp(i) = Mid(Query, ((i - 1) * StrLen) + 1, StrLen)&lt;br&gt;
&#160; &#160;&lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; i&lt;br&gt;
&#160; &#160;StringToArray = Temp&lt;br&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Function&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;
</description>
		<content:encoded><![CDATA[<p>Dick, Brett..<br />
Thanks for those suggestions.</p>
<p>I just modified the code&#8230;changed WHERE/OR to WHERE IN and used a String to Array Function&#8230;.ran a query of about 5000 Customer ID&#8217;s typed in a range of cells&#8230; works great&#8230; thanks for this post..</p>
<div style="overflow: auto; white-space: nowrap;" class="codecolorer-container vb default">
<div style="white-space: nowrap;" class="vb codecolorer"><span class="kw1">Option</span> <span class="kw1">Explicit</span><br />
&nbsp;<br />
<span class="kw1">Sub</span> QSC_PARM()<br />
<span class="co1">&#8216;Queries the Customer Master<br />
</span><span class="kw1">Dim</span> Ar <span class="kw1">As</span> <span class="kw1">String</span>, Ar1 <span class="kw1">As</span> <span class="kw1">String</span>, Ar2 <span class="kw1">As</span> <span class="kw1">String</span>, Ar3 <span class="kw1">As</span> <span class="kw1">String</span><br />
<span class="kw1">Dim</span> SorSht <span class="kw1">As</span> <span class="kw1">String</span>, QryNm <span class="kw1">As</span> <span class="kw1">String</span><br />
<span class="kw1">Dim</span> DestSht <span class="kw1">As</span> Worksheet<br />
<span class="kw1">Dim</span> i <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp;<br />
SorSht = <span class="st0">&#8220;Sheet1$&#8221;</span><br />
<span class="kw1">Set</span> DestSht = Sheet2<br />
&nbsp;QryNm = <span class="st0">&#8220;QRY_PARM&#8221;</span><br />
<span class="kw1">ReDim</span> RngArr(1 <span class="kw1">To</span> Range(<span class="st0">&#8220;ID&#8221;</span>).Count)<br />
&nbsp;<br />
Ar1 = <span class="st0">&#8220;ODBC;DSN=Excel Files;DBQ=&#8221;</span> &amp;amp; Range(<span class="st0">&#8220;VBA_FPN&#8221;</span>).Value &amp;amp; <span class="st0">&#8220;;DefaultDir=&#8221;</span> &amp;amp; Range(<span class="st0">&#8220;VBA_FP&#8221;</span>).Value &amp;amp; <span class="st0">&#8220;;DriverId=790;MaxBufferSize=2048;PageTimeout=5;&#8221;</span><br />
Ar = <span class="st0">&#8220;SELECT *&#8221;</span><br />
Ar2 = Ar &amp;amp; <span class="st0">&#8220;&#8221;</span> &amp;amp; Chr(10) &amp;amp; <span class="st0">&#8220;FROM &#8216;&#8221;</span> &amp;amp; Range(<span class="st0">&#8220;VBA_FPN1&#8243;</span>).Value &amp;amp; <span class="st0">&#8220;&#8216;.&#8217;&#8221;</span> &amp;amp; SorSht &amp;amp; <span class="st0">&#8220;&#8216; &#8216;&#8221;</span> &amp;amp; SorSht &amp;amp; <span class="st0">&#8220;&#8216;&#8221;</span> &amp;amp; Chr(10) &amp;amp; Chr(13) &amp;amp; <span class="st0">&#8220;WHERE &#8216;&#8221;</span> &amp;amp; SorSht &amp;amp; <span class="st0">&#8220;&#8216;.ID IN (&#8220;</span><br />
Ar3 = Range(<span class="st0">&#8220;ID&#8221;</span>)(1).Value<br />
&nbsp;<br />
<span class="kw1">For</span> i = 2 <span class="kw1">To</span> Range(<span class="st0">&#8220;ID&#8221;</span>).Count<br />
Ar3 = Ar3 &amp;amp; <span class="st0">&#8220;, &#8220;</span> &amp;amp; Range(<span class="st0">&#8220;ID&#8221;</span>)(i).Value<br />
<span class="kw1">Next</span> i<br />
&nbsp;<br />
Ar2 = Ar2 &amp;amp; Ar3 &amp;amp; <span class="st0">&#8220;)&#8221;</span><br />
&nbsp;<br />
<span class="kw1">With</span> DestSht.QueryTables(QryNm)<br />
Ar3 = Replace(Ar1, <span class="st0">&#8220;ODBC&#8221;</span>, <span class="st0">&#8220;OLEDB&#8221;</span>, 1, 1)<br />
.Connection = Ar3<br />
.CommandText = StringToArray(Ar2)<br />
.Connection = Ar1<br />
.CommandText = StringToArray(Ar2)<br />
<span class="kw1">End</span> <span class="kw1">With</span><br />
DestSht.QueryTables(QryNm).Refresh BackgroundQuery:=<span class="kw1">False</span><br />
<span class="kw1">End</span> <span class="kw1">Sub</span><br />
&nbsp;<br />
<span class="kw1">Function</span> StringToArray(Query <span class="kw1">As</span> <span class="kw1">Variant</span>) <span class="kw1">As</span> <span class="kw1">Variant</span><br />
&nbsp;<br />
&nbsp; &nbsp;<span class="kw1">Const</span> StrLen = 127<br />
&nbsp; &nbsp;<span class="kw1">Dim</span> NumElems <span class="kw1">As</span> <span class="kw1">Integer</span><br />
&nbsp; &nbsp;<span class="kw1">Dim</span> Temp() <span class="kw1">As</span> <span class="kw1">String</span><br />
&nbsp; &nbsp;<span class="kw1">Dim</span> i <span class="kw1">As</span> <span class="kw1">Long</span><br />
&nbsp; &nbsp;NumElems = (Len(Query) / StrLen) + 1<br />
&nbsp; &nbsp;<span class="kw1">ReDim</span> Temp(1 <span class="kw1">To</span> NumElems) <span class="kw1">As</span> <span class="kw1">String</span><br />
&nbsp; &nbsp;<span class="kw1">For</span> i = 1 <span class="kw1">To</span> NumElems<br />
&nbsp; &nbsp; &nbsp; Temp(i) = Mid(Query, ((i &#8211; 1) * StrLen) + 1, StrLen)<br />
&nbsp; &nbsp;<span class="kw1">Next</span> i<br />
&nbsp; &nbsp;StringToArray = Temp<br />
<span class="kw1">End</span> <span class="kw1">Function</span></div>
</div>
]]></content:encoded>
	</item>
</channel>
</rss>

