I had a similar problem with a spreadsheet function that occupied a range as an object. In my case, I wanted to do a simple search for a fixed set of values ββ(in another array).
The problem is that your "column" variable does not contain a column - it contains a 2D array. Therefore, each value represents its own string (the array itself).
I know that I could execute the following example using the existing function in the spreadsheet, but this is a worthy demonstration of working with a 2D array to find the value:
function flatten(range) { var results = []; var row, column; for(row = 0; row < range.length; row++) { for(column = 0; column < range[row].length; column++) { results.push(range[row][column]); } } return results; } function getIndex(range, value) { return flatten(range).indexOf(value); }
So, since I wanted to just search the entire range for the existence of the value, I just flattened it into a single array. If you are really dealing with 2D ranges, this type of flattening and index grabbing may not be very useful. In my case, I looked through the column to find the intersection of the two sets.
Aggieric
source share