0

I found a Google App Script here by Cooper, user:7215091, from this thread

And it works perfectly for my needs where I too was removing duplicates from a Google Sheet looking at values in column B in a sheet that is constantly being updated by outside users.

The only thing I want it to do is ignore case. What needs to be edited so that it will remove duplicates, ignoring the case? For example it finds "Bob", "bob", and "boB" and it removes two, doesn't matter which.

  function removeDuplicates() {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getActiveSheet();
  var rg=sh.getDataRange();
  var row=rg.getRow();
  var col=rg.getColumn();
  var vA=rg.getValues();
  var nA=[];
  var duplicate=true;
  for(var i=0;i<vA.length;i++)
  {
    duplicate=false;
    for(var j=0;j<nA.length;j++)
    {
      if(vA[i][1]==nA[j][1])
      {
        duplicate=true;
        nA[j]=vA[i];
      }
    }
    if(!duplicate)
    {
      nA.push(vA[i]);
    }
  }
  rg.clearContent();
  sh.getRange(row, col, nA.length, nA[0].length).setValues(nA);
}

1 Answer 1

0

Use toLowerCase() to convert each of the strings to lowercase letters and compare them.

  if(vA[i][1].toLowerCase() === nA[j][1].toLowerCase())
  {
    duplicate=true;
    nA[j]=vA[i];
  }
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.