title: Filter data by column K in Google Script Editor (Google Sheets)
body: <p>In this example, I have a set of data from a Google Sheet (4Cat) feeding into another sheet (ImportFeeder) where I am running my Google Script.</p>
  
  <p>At the end of the script below, how can I insert a filter script to sort the data by Row K? (only showing iPad products)</p>
  
  <p><a href="https://i.stack.imgur.com/GqckL.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/GqckL.jpg" alt="enter image description here"></a></p>
  
  <pre><code>function myFunction() {
  var sss = SpreadsheetApp.openById('1kL96dRm3Z8XBtMXnSzUARxR1b34-njlkZQ1sU0c3g1s'); //replace with source ID
  var ss = sss.getSheetByName('4cat'); //replace with source Sheet tab name
  var range = ss.getRange('A:I'); //assign the range you want to copy
  var data = range.getValues();
  
  var tss = SpreadsheetApp.openById('1u7547KaniKHLUJn2v-ezN4l8ZcxE4viCFcoxsA904MI'); //replace with destination ID
  var ts = tss.getSheetByName('Sheet1'); //replace with destination Sheet tab name
  ts.getRange(ts.getLastRow()+1, 1, data.length, data[0].length).setValues(data);
  
  var range = ts.getRange(ts.getLastRow()+1, 1, data.length, data[0].length)
  var rawData = range.getValues()     // get value from spreadsheet 2
  var data = []                       // Filtered Data will be stored in this array
  for (var i = 0; i&lt; rawData.length ; i++){
  if(rawData[i][10] == "iPad")            // Check to see if column K says ipad if not skip it
  {
  data.push(rawData[i])
  }
  }
  }
  </code></pre>
  
  <p>(Cannot read property length from undefined)</p>
  
  <p>4Cat Sample Data <a href="https://docs.google.com/spreadsheets/d/1kL96dRm3Z8XBtMXnSzUARxR1b34-njlkZQ1sU0c3g1s/edit?usp=sharing" rel="noreferrer">https://docs.google.com/spreadsheets/d/1kL96dRm3Z8XBtMXnSzUARxR1b34-njlkZQ1sU0c3g1s/edit?usp=sharing</a> */</p>
  
  <p><em>feeding into</em></p>
  
  <p>ImportFeeder <a href="https://docs.google.com/spreadsheets/d/1u7547KaniKHLUJn2v-ezN4l8ZcxE4viCFcoxsA904MI/edit?usp=sharing" rel="noreferrer">https://docs.google.com/spreadsheets/d/1u7547KaniKHLUJn2v-ezN4l8ZcxE4viCFcoxsA904MI/edit?usp=sharing</a></p>
  
  <p><strong>Required</strong> - Successful sheet to sheet import, filter data by Row K within Google Scripts. Add a clear() sheet function to the top of the script, as this will be running daily and the sheet needing clearing before daily import.</p>