1

I'm trying to avoid removing rows from sheets when copying and removing duplicates to another specified sheet.

In this case, the 'TestSheet' sheet is removing rows (The sheets need to stay static). I'd like to send the range to an array and manipulate the data there, and then add to another sheet (or export to csv eventually). Any help would be appreciated! Here's the code:

function copyNSavetest(){
  var ss = SpreadsheetApp.getActive();
  var scanSheetSheet = ss.getSheetByName('TestSheet');

  var scannedContents = [];
  var scannedContents = scanSheetSheet.getRange("A2:C500");
  Logger.log(scannedContents.getValues());

  scannedContents.removeDuplicates([1]);
  Logger.log(scannedContents.getValues());


}
2
  • Define a duplicate. Commented Jun 7, 2020 at 20:19
  • The same cell text in the first column of the 3 Commented Jun 7, 2020 at 20:36

1 Answer 1

1
function getUniqueArray(){
  const ss=SpreadsheetApp.getActive();
  const tsh=ss.getSheetByName('TestSheet');
  const tvs=tsh.getRange("A2:C500").getValues();
  let uA=[];
  let uB=[];
  tvs.forEach(function(r){
    let s=String(r[0]);
    if(uA.indexOf(s)==-1) {
      uA.push(s);
      uB.push(r);
    }
  });
  return uB;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.