title: How to transfer selected data from 50 Excel workbooks to a single workbook?
body: <p>Loop in folder works, but loop on cells doesn't. I have a folder with 50 Excel files and a destination Excel file. Data should go from folder to the destination Excel file:</p>
  <p> </p>
  <pre><code>#include &lt;file.au3&gt;
  #include &lt;Excel.au3&gt;
  opt(&quot;WinTitleMatchMode&quot;, 2)
  $path = &quot;C:\Users\User\Desktop\Nezavisimai\Papka2\&quot;
  $FileListShort = _FileListToArray($path, &quot;*.xlsx&quot;, 1, True)
  $ProgExcel = _Excel_Open()
  $workbookDestiny = _Excel_BookNew($ProgExcel)
  
  $LineDestiny = 1
  _Excel_RangeWrite($workbookDestiny, $workbookDestiny.Activesheet, &quot;Sample type&quot;, &quot;A&quot; &amp; $LineDestiny)
  _Excel_RangeWrite($workbookDestiny, $workbookDestiny.Activesheet, &quot;Sample name&quot;, &quot;B&quot; &amp; $LineDestiny)
  _Excel_RangeWrite($workbookDestiny, $workbookDestiny.Activesheet, &quot;Result&quot;, &quot;C&quot; &amp; $LineDestiny)
  
  For $i = 1 to $FileListShort[0]
  
  $workbookSource =  _Excel_BookOpen($ProgExcel, $FileListShort[$i], False, False)
  For $LineSource = 2 to 30
  $sampletype = _Excel_RangeRead($workbookSource, &quot;Данные&quot;, &quot;A&quot; &amp; $LineSource)
  $samplename = _Excel_RangeRead($workbookSource, &quot;Данные&quot;, &quot;B&quot; &amp; $LineSource)
  $sampleresult = _Excel_RangeRead($workbookSource, &quot;Данные&quot;, &quot;C&quot; &amp; $LineSource)
  $sampleobs = _Excel_RangeRead($workbookSource, &quot;Данные&quot;, &quot;D&quot; &amp; $LineSource)
  If $sampletype = &quot;Sample&quot;  Then
      If $sampleobs &lt;&gt; &quot;Over limit&quot; Then
          $LineDestiny = $LineDestiny + 1
          _Excel_RangeWrite($workbookDestiny, &quot;Лист1&quot;, $sampletype, &quot;A&quot; &amp; $LineDestiny)
          _Excel_RangeWrite($workbookDestiny, &quot;Лист1&quot;, $sampletype, &quot;B&quot; &amp; $LineDestiny)
          _Excel_RangeWrite($workbookDestiny, &quot;Лист1&quot;, $sampletype, &quot;C&quot; &amp; $LineDestiny)
       EndIF
  EndIF
  Next
  _Excel_BookClose($workbookSource, False)
  Next
  </code></pre>
  <p>Problems may be in here:</p>
  <pre><code>If $sampletype = &quot;Sample&quot;  Then
          If $sampleobs &lt;&gt; &quot;Over limit&quot; Then
             $LineDestiny = $LineDestiny + 1
  </code></pre>