<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic For loop in macro not working when select field in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285247#M106070</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did find the solution, a rather obvious one actually. But sometimes you are blind when looking at your own code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I in the first one selects Excluded values, I only get values that are excluded.And since they are excluded I can't select them. If I cleared other selections after the getExludedValues it would be possible to select them.&lt;/P&gt;&lt;P&gt;I my case I didn't want to clear the other selections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Working code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vCustomers.SelectPossible&lt;/P&gt;&lt;P&gt;set vCompanies = vCustomers.GetSelectedValues(10000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; for i = 0 to vCompanies.Count-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set vCompanyName=vCompanies.Item(i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("CONCERN_NAME").Select vCompanies.Item(i).Text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vCurrency=ActiveDocument.GetField("CurrencyCode_Reporting").GetPossibleValues.Item(0).Text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("CurrencyCode").Select vCurrency&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call someMethod()&lt;/P&gt;&lt;P&gt;&amp;nbsp; next&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2011 08:37:57 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-08-03T08:37:57Z</dc:date>
    <item>
      <title>For loop in macro not working when select field</title>
      <link>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285243#M106066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See enclosed code. As you can see I retrieve all excluded values(getselected is not used, since it has a ' in front).&lt;/P&gt;&lt;P&gt;I get 4078 records. In the loop for debugging purpose i only loop 10 times.&lt;/P&gt;&lt;P&gt;When I get the current Item in the loop and display the text in the msgbox I can see that I get the correct value.&lt;/P&gt;&lt;P&gt;But when I try to select this value in the field nothing happens.&lt;/P&gt;&lt;P&gt;In the 2 last lines I did test selecting * which works and I hardcoded "2Big" which also works. I have searched the forum and seen that:&lt;/P&gt;&lt;P&gt;ActiveDocument.GetField("CONCERN_NAME").Select trim(vCompanies.Item(i).Text)&amp;nbsp; should work. The trim is just added to secure no extra spaces is there. Removing the trim won't change the result.&lt;/P&gt;&lt;P&gt;I'm using Qlikview 10 SR1 64 bit.&lt;/P&gt;&lt;P&gt;Can anyone please suggest why it's not working.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sub AutoExport&lt;/P&gt;&lt;P&gt; dim vCustomers&lt;/P&gt;&lt;P&gt; dim activeSheet&lt;/P&gt;&lt;P&gt; dim vCompanies&lt;/P&gt;&lt;P&gt; dim vCompanyName&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; set activeSheet = ActiveDocument.ActiveSheet&lt;/P&gt;&lt;P&gt; set vCustomers = ActiveDocument.GetField("CONCERN_NAME") &lt;/P&gt;&lt;P&gt; 'set vCompanies = vCustomers.GetSelectedValues&lt;/P&gt;&lt;P&gt; set vCompanies = vCustomers.GetExcludedValues(10000)&lt;/P&gt;&lt;P&gt;&amp;nbsp; for i = 0 to 10'vCompanies.Count-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set vCompanyName=vCompanies.Item(i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; qvlib.MsgBox(vCompanyName.Text)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.GetField("CONCERN_NAME").Select trim(vCompanies.Item(i).Text)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'ActiveDocument.GetField("CONCERN_NAME").Select "*"&amp;nbsp;&amp;nbsp; '//This works, but select all!!!!!!! &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'ActiveDocument.GetField("CONCERN_NAME").Select "2Big" '//This works also, but hardcoding every possible records is not possible!!!!!!! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call Nextmethod()&lt;/P&gt;&lt;P&gt; next&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 07:14:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285243#M106066</guid>
      <dc:creator />
      <dc:date>2011-06-14T07:14:42Z</dc:date>
    </item>
    <item>
      <title>For loop in macro not working when select field</title>
      <link>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285244#M106067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;try&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("CONCERN_NAME").Select vCompanies.Item(i).Text&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 09:30:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285244#M106067</guid>
      <dc:creator />
      <dc:date>2011-06-14T09:30:58Z</dc:date>
    </item>
    <item>
      <title>For loop in macro not working when select field</title>
      <link>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285245#M106068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your response.&lt;/P&gt;&lt;P&gt;I just tested&lt;/P&gt;&lt;P&gt;ActiveDocument.Fields("CONCERN_NAME").Select vCompanies.Item(i).Text&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it didn't help &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; , same result.&lt;/P&gt;&lt;P&gt;Do you know the difference between field and fields. In the Api Doc, as I read it, I can only find Field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 09:53:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285245#M106068</guid>
      <dc:creator />
      <dc:date>2011-06-14T09:53:28Z</dc:date>
    </item>
    <item>
      <title>For loop in macro not working when select field</title>
      <link>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285246#M106069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A small update from my own testing. If I replace:&lt;/P&gt;&lt;P&gt;set vCompanies = vCustomers.GetExcludedValues(10000)&lt;/P&gt;&lt;P&gt;with&lt;/P&gt;&lt;P&gt;set vCompanies = vCustomers.GetSelectedValues(10000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it works as it should &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But it shouldn't from a technical point of view matter which of these we use. Something for the support maybe.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jun 2011 09:55:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285246#M106069</guid>
      <dc:creator />
      <dc:date>2011-06-17T09:55:48Z</dc:date>
    </item>
    <item>
      <title>For loop in macro not working when select field</title>
      <link>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285247#M106070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did find the solution, a rather obvious one actually. But sometimes you are blind when looking at your own code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I in the first one selects Excluded values, I only get values that are excluded.And since they are excluded I can't select them. If I cleared other selections after the getExludedValues it would be possible to select them.&lt;/P&gt;&lt;P&gt;I my case I didn't want to clear the other selections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Working code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vCustomers.SelectPossible&lt;/P&gt;&lt;P&gt;set vCompanies = vCustomers.GetSelectedValues(10000)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; for i = 0 to vCompanies.Count-1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set vCompanyName=vCompanies.Item(i)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("CONCERN_NAME").Select vCompanies.Item(i).Text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vCurrency=ActiveDocument.GetField("CurrencyCode_Reporting").GetPossibleValues.Item(0).Text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ActiveDocument.Fields("CurrencyCode").Select vCurrency&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call someMethod()&lt;/P&gt;&lt;P&gt;&amp;nbsp; next&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2011 08:37:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/For-loop-in-macro-not-working-when-select-field/m-p/285247#M106070</guid>
      <dc:creator />
      <dc:date>2011-08-03T08:37:57Z</dc:date>
    </item>
  </channel>
</rss>

