How do i copy the whole row if the value in a particular column is as required?

I need some help here…
What I want to do is copy all the rows from a sheet which have a value ‘open POs’ in column R in other words every row that has a value ‘open POs’ in column R should be copied to another google sheet.

Please help…

34 thoughts on “How do i copy the whole row if the value in a particular column is as required?”

  1. Try this:

    Code:

    function myFunction() {
      // Source sheet is the current sheet
      var srcSheet = SpreadsheetApp.getActiveSheet();
      // Open destination sheet using spreadsheet ID found in url
      // See reference below on how top locate spreadsheet id
      var dstSheet = SpreadsheetApp.openById('destination sheet ID');
    
      // Get values of source sheet
      var srcData = srcSheet.getDataRange().getValues();
    
      srcData.forEach(function(row){
        // If column R is 'open POs'
        if(row[17] == 'open POs') {
          // Add to last row of dstSheet
          dstSheet.appendRow(row)
        }
      });
    }
    

    Data Sample:

    sample

    Output:

    output

    Note:

    • Columns hidden for column R visibility

    Reference:

    Reply

Leave a Comment