Copy non-empty range into new sheet, and drag down formulas
<ol>
<li><p>I want to copy all the non-empty cells in columns A/B from sheet "Consolidation Sheet" and then paste these cells into the sheet "Inputs for Web App" into columns H:I (always starting from the top, rather than appending them as new rows, since these values will be updated constantly).</p></li>
<li><p>Then I basically want to drag down all of the formulas in the other columns (A through G) all the way down to the last row pasted.</p></li>
<li><p>Format column I as a date.</p></li>
</ol>

<p>I'm not sure if I need a loop to do this or just an array. I've tried it both ways but keep getting errors.</p>

<p>option 1: HERE I GET THIS ERROR: </p>

<blockquote>
  <p>TypeError: (class)@2e3b19c is not a function, it is object.</p>
</blockquote>

<pre><code>function copynotempty(){
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("CONSOLIDATION SHEET");
  var col = 0 ; // choose the column you want to check: 0 = col A, 1= col B ...
  var lastrow = ss.getLastRow();
  var range = ss.getRange(5,1,lastrow-4,2);
  var values=range.getValues();// data is a 2D array, index0 = col A
  var formulas=range.getFormulas();// data is a 2D array, index0 = col A
  var target= new Array();// this is a new array to collect data
   //for(n=0;n&lt;range.getHeight();++n){
     if (values()!=''|| formulas()!=''){ ;  (
           var sh2=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Inputs for Web App"); //target sheet of the spreadsheet
           range.copyTo(sh2.getRange(4,8,range.height,range[0].length),{contentsOnly:true});
              }
            }
</code></pre>

<p>option 2: here I keep getting this error: </p>

<blockquote>
  <p>"TypeError: Cannot set property "0.0" of undefined to "(VALUE OF
  CELL)"</p>
</blockquote>

<pre><code>function copynotempty(){
  var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("CONSOLIDATION SHEET");
  var col = 0 ; // choose the column you want to check: 0 = col A, 1= col B ...
  var lastrow = ss.getLastRow();
  var range = ss.getRange(5,1,lastrow-4,2);
  var values=range.getValues();// data is a 2D array, index0 = col A
  var formulas=range.getFormulas();// data is a 2D array, index0 = col A
  var target= new Array();// this is a new array to collect data
for(n=0;n&lt;range.getHeight();++n){
     if (values[n][col]!=''|| formulas[n][col]!=''){ ;
        for (cc=0;cc&lt;range.getWidth();++cc){
                if (values[n][cc]!=''){target[n][cc]=values[n][cc]} // if the cell has a value, copy it  
                }
              }
            }
            if(target.length&gt;0){// if there is something to copy
              var sh2=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Inputs for Web App"); //second sheet of your spreadsheet
          sh2.getRange(4,8,target.height,target[0].length).setValues();// paste the selected values in the 2cond sheet
          }
        }
</code></pre>