I have the following script that works well in google docs --> sheets. It doesn't work well with a lot of rows. I am guessing because of the array that keeps getting bigger that tracks the values.
I need a script I can run in MS EXCEL that will remove rows that have a duplicate value in a column. (Unless the column is "")
Google docs script that works for small files:
function removeDuplicates()
{
var s = SpreadsheetApp.getActiveSheet();
var c = Browser.inputBox("Please", "Type in the column name (e.g.: A, B, etc.)", Browser.Buttons.OK_CANCEL);
var r, v;
var aValues = [];
try
{
if(c != "cancel")
{
r = 2; // first row is row two
while (r <= s.getLastRow())
{
v = s.getRange(c + r).getValue();
if(v != "")
{
if(aValues.indexOf(v) == -1)
{
aValues.push(v);
}
else
{
s.deleteRow(r);
continue;
}
}
r++;
}
Browser.msgBox("Duplicates removed!");
}
} catch (e) {Browser.msgBox("Error Alert:", e.message, Browser.Buttons.OK);}
}
Any help would be appreciated.