I'm trying to filter a range by comparing it to another range. I couldn't figure out a way to do this with functions in Google Spreadsheets so I made my own.
function FilterByArray(range, filterRange)
{
var rangeLength = range.length;
var filterRangeLength = filterRange.length;
var outputArray = [];
for(i = 0; i < rangeLength; i++)
{
var rangeValue = range[i];
for(ii = 0; ii < filterRangeLength; i++)
{
if(rangeValue == filterRange[ii])
{
outputArray.push(rangeValue);
}
}
}
return outputArray;
}
At first glance I thought this would work, and should process in milliseconds with only a couple thousand total iterations. I try and test it and it says Loading...
for 10-20 seconds then errors out with Internal Error executing the custom function
.
Why is this, and what can I do to fix it?
Edit: A note, I come from C#, so if there are any glaring issues in this that are unrelated to my question please let me know.