<?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 Re: Macro to Count Rows and Export to Excel in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365978#M702251</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 think that &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If CellRect.Height &amp;gt; 500 Then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;should probably read &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If CellMatrix.Count &amp;gt; 500 Then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not tested though...&lt;/P&gt;&lt;P&gt;Jonathan&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Oct 2012 11:40:38 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2012-10-08T11:40:38Z</dc:date>
    <item>
      <title>Macro to Count Rows and Export to Excel</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365975#M702248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just wanted to share a Macro I created for a solution I was developing within a QVW file. I have a file with multiple "views" of the data. They're intended to take the user from a high-level view slowly to the details with the last view displaying a sample of the data and an export button. The export button simply runs the following Macro to send the data to Excel. But I wanted to be able to put a limitation of x rows so that the user doesn't accidentally export 100k rows, etc. So here's an example of what I came up with and it worked perfect for my needs:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;Sub&lt;/STRONG&gt;&lt;/SPAN&gt; Export_View1&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #00bd36;"&gt;&lt;STRONG&gt;'First we determine which object and how many rows of data it has.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;/SPAN&gt; obj = ActiveDocument.GetSheetObject( &lt;SPAN style="color: #1e39f6;"&gt;"CH001"&lt;/SPAN&gt; )&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;/SPAN&gt; CellMatrix = obj.GetCells( CellRect )&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #00bd36;"&gt;&lt;STRONG&gt;'Next we determine if the number of rows of the object is more than the maximum allowed.&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #00bd36;"&gt;&lt;STRONG&gt;'If it is then we display the message below in the MSGBOX:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;If&lt;/STRONG&gt;&lt;/SPAN&gt; CellRect.Height &amp;gt; 500 &lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;Then&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #1e39f6;"&gt;&lt;STRONG&gt;MSGBOX&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;"Transaction count is greater than 500. Please limit selections to 500 transactions or less."&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #1e39f6;"&gt;&lt;STRONG&gt;Else&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #00bd36;"&gt;&lt;STRONG&gt;'If it is not &amp;gt; the maximum allowed we then export the data to Excel:&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;ActiveDocument.GetSheetObject(&lt;SPAN style="color: #1e39f6;"&gt;"CH001"&lt;/SPAN&gt;).CopyTableToClipboard &lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;true &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #1e39f6;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; XLApp = &lt;/SPAN&gt;&lt;STRONG&gt;CreateObject&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;(&lt;/SPAN&gt;"Excel.Application"&lt;SPAN style="color: #000000;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;XLApp.Visible = &lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;True &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;/SPAN&gt; XLDoc = XLApp.Workbooks.Add &lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;/SPAN&gt; XLSheet = XLDoc.Worksheets(1) &lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #1e39f6;"&gt;&lt;SPAN style="color: #000000;"&gt;XlSheet.Name=&lt;/SPAN&gt;"Custom Worksheet Name" &lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;XLSheet.Paste XLSheet.Range(&lt;SPAN style="color: #1e39f6;"&gt;"A1"&lt;/SPAN&gt;) &lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;/SPAN&gt; Selection = XLSheet.Cells &lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;With Selection&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;.VerticalAlignment = 1&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;.WrapText = &lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;True &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;.Borders.ColorIndex = 0&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;.ColumnWidth = 11&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #00bd36;"&gt;&lt;STRONG&gt;'When the export finishes we display the below message: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;MSGBOX&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;"Export Complete!"&lt;SPAN style="color: #000000;"&gt;,VbInformation&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px;"&gt;&lt;SPAN style="color: #1e39f6;"&gt;&lt;STRONG&gt;End&lt;/STRONG&gt;&lt;/SPAN&gt; With&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #1e39f6;"&gt;&lt;STRONG&gt;End&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;If&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin: 0.0px 0.0px 0.0px 0.0px; color: #1e39f6;"&gt;&lt;STRONG&gt;End&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;&lt;STRONG&gt;Sub &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I hope you find this useful too!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2012 17:17:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365975#M702248</guid>
      <dc:creator>jcampbell</dc:creator>
      <dc:date>2012-07-24T17:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Count Rows and Export to Excel</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365976#M702249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hh Josh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What QV version do you have this working with?&amp;nbsp; I can't get it working with v11 SR2. SEems to get stuck at:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff; font-family: Arial; color: #1e39f6;"&gt;&lt;STRONG&gt;Set&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #737373; font-family: Arial; background-color: #ffffff;"&gt; CellMatrix = obj.GetCells( CellRect )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 07 Oct 2012 21:13:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365976#M702249</guid>
      <dc:creator>Jason_Michaelides</dc:creator>
      <dc:date>2012-10-07T21:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Count Rows and Export to Excel</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365977#M702250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;He's pulling CellRect out of thin air &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/wink.png" /&gt; &lt;/P&gt;&lt;P&gt;Add this line: Set CellRect = ActiveDocument.GetApplication().GetEmptyRect()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 11:21:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365977#M702250</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2012-10-08T11:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Count Rows and Export to Excel</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365978#M702251</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 think that &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If CellRect.Height &amp;gt; 500 Then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;should probably read &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If CellMatrix.Count &amp;gt; 500 Then&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not tested though...&lt;/P&gt;&lt;P&gt;Jonathan&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 11:40:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365978#M702251</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2012-10-08T11:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Count Rows and Export to Excel</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365979#M702252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nope, but obj.GetRowCount() works.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 12:08:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365979#M702252</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2012-10-08T12:08:18Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to Count Rows and Export to Excel</title>
      <link>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365980#M702253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rownum()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Oct 2012 12:44:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Macro-to-Count-Rows-and-Export-to-Excel/m-p/365980#M702253</guid>
      <dc:creator />
      <dc:date>2012-10-08T12:44:21Z</dc:date>
    </item>
  </channel>
</rss>

