title: Apps Script: Check if range is empty and copy data
body: <p>I'm trying to build an automated list with google sheets. The first sheet(A) is for input of production data of a week. The second sheet(B) should be the data archive. Thus i want the content from sheet A copied to sheet B and then deleted in sheet a. It should be copied in the next empty range in sheet B.</p>
  <p>My problem must be inside the notation of the &quot;while&quot; or / and the &quot;if&quot; but nothing seems to work properly.</p>
  <p>The while checks if sheet A is already emptied, if not the &quot;if&quot; function checks a specific range in sheet B if it is empty. If thats the case it should be copying the data and then delete it. Else the column of the range in sheet b is changed to the next range (spaltennummer + 6).</p>
  <p>While troubleshooting it either stays in the while (finds no empty range?) or it runs through without any effect. I tried &quot;== 0&quot;, &quot;== &quot;&quot;&quot;, isblank and so on. (every option available?). Google didnt seem able to provide me an answer...</p>
  <p>Thanks for ur help.</p>
  <p>Code:</p>
  <pre><code>function myFunction() {}
  function leerzelle(){
   
    var spaltennummer = 4;
    var rangeDatenarchiv = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&quot;Tabellenblatt1&quot;).getRange(8,spaltennummer,15,5);
    var rangeDateneingabe = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(&quot;Dateneingabe&quot;).getRange(&quot;J8:N22&quot;);
    var values = rangeDateneingabe.getValues();
  
  while(rangeDateneingabe !== 0){
   
    if(rangeDatenarchiv == 0) {
      rangeDatenarchiv.setValues(values);
      rangeDateneingabe.setValues(&quot;&quot;);
    }
    else{
      spaltennummer = spaltennummer + 6;
      
    }
   
  }
  }
  </code></pre>